reference
reference copied to clipboard
Type paremters constraints in generic implementations description is inaccurate
https://doc.rust-lang.org/reference/items/implementations.html#generic-implementations
Generic parameters constrain an implementation if the parameter appears at least once in one of:
- ...
- As an associated type in the bounds of a type that contains another parameter that constrains the implementation
However, RFC 447 says that all parameters should be constrained:
Type parameters are legal if they are "constrained" according to the following inference rules:
- ...
- If
<T0 as Trait<T1...Tn>>::U == Vappears in the impl predicates, andT0...Tnare constrained andT0 as Trait<T1...Tn>is not the impl trait reference thenVis constrained.
This is also what implemented by the compiler.
See also Why does Fn() -> T constrain T but Fn(T) -> T does not.