You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using HKL and associated types, one can write constraints that should be accepted which the compiler rejects (mostly using the IntoIterator: IntoIter: Iterator: IteratorWithSomeProperty hierarchy).
'Motivating' example here and a minimal one here. The intermediate trait is required to show the error.
To reiterate what's in the comments of the first example, consider the following trait and function:
Does Vec<A> satisfy these constraints? &'a Vec<A> has an IntoIterator implementation via Deref<Target=[A]> (this indirection isn't the issue: we can make a newtype wrapper around Vec<A> which directly implements IntoIterator and still exhibits the problem).
We have <&'a Vec<A> as IntoIterator>::IntoIter == Iter<'a, A>, and Iter<'a, A>: ExactSizeIterator>, so this should satisfy the constraints given in fancy_constraints above. Instead, we get the following error message:
error: the trait bound `for<'a> <&'a _ as std::iter::IntoIterator>::IntoIter: std::iter::ExactSizeIterator` is not satisfied [--explain E0277]
--> <anon>:13:5
13 |> fancy_constraints(vec![0u8]);
|> ^^^^^^^^^^^^^^^^^
help: the following implementations were found:
help: <&'a mut I as std::iter::ExactSizeIterator>
note: required by `fancy_constraints`
The help message is somewhat confusing (I couldn't find the implementation it mentions, but I didn't look very hard), and I couldn't find a way to use it to fix the problem.
The text was updated successfully, but these errors were encountered:
Using HKL and associated types, one can write constraints that should be accepted which the compiler rejects (mostly using the
IntoIterator: IntoIter: Iterator: IteratorWithSomeProperty
hierarchy).'Motivating' example here and a minimal one here. The intermediate trait is required to show the error.
To reiterate what's in the comments of the first example, consider the following trait and function:
Does
Vec<A>
satisfy these constraints?&'a Vec<A>
has anIntoIterator
implementation viaDeref<Target=[A]>
(this indirection isn't the issue: we can make a newtype wrapper aroundVec<A>
which directly implementsIntoIterator
and still exhibits the problem).We have
<&'a Vec<A> as IntoIterator>::IntoIter == Iter<'a, A>
, andIter<'a, A>: ExactSizeIterator>
, so this should satisfy the constraints given infancy_constraints
above. Instead, we get the following error message:The help message is somewhat confusing (I couldn't find the implementation it mentions, but I didn't look very hard), and I couldn't find a way to use it to fix the problem.
The text was updated successfully, but these errors were encountered: