-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use generic ViewMut iterator? #157
Comments
Hi! The "big problem" with In your first function you have a concrete type with a concrete tracking type. In this case your not tracking anything so In your second function there is no concrete type, only a generic. So the compiler will try to find an fn weird<T: Component + MutTrait>(mut v: ViewMut<T>)
where
for<'a, 'b> &'a mut ViewMut<'b, T>: IntoIter,
for<'a, 'b> <<&'a mut ViewMut<'b, T> as IntoIter>::IntoIter as Iterator>::Item:
DerefMut<Target = T>,
{
for mut x in (&mut v).iter() {
x.mutmut();
println!("This is a kind of a mutable reference");
}
}
For your third function it starts just like the second one. The compiler tries to find an I hope this helps understand the issue and how to fix it. |
Thank you for the thorough explanation! |
Using shipyard 0.6.2
In the code below there are three functions.
The first function displays the expected behavior.
The second function yields a compilation error when trying to mutate x (x has type
&T
and not&mut T
).The third function yields a compilation error when
iter()
is called, with the error describing unsatisfiedIntoAbstract
trait bounds.I am unsure of why this behavior occurs.
There was some discussion in #151 about using the get trait as generic.
As of yet I have been unable to solve my issue by referencing that discussion.
Why is this happening and what might I do to fix it?
I do not seem to be knowledgeable enough to resolve it out on my own.
The error produced by the third function:
The text was updated successfully, but these errors were encountered: