-
Notifications
You must be signed in to change notification settings - Fork 43
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 with_id? #191
Comments
This should work but doesn't for some lifetime reason. // `IntoAbstract` would have to be implemented for the type `&'0 mut shipyard::ViewMut<'1, Component1>`, for any two lifetimes `'0` and `'1`...
// ...but `IntoAbstract` is actually implemented for the type `&mut shipyard::ViewMut<'2, Component1>`, for some specific lifetime `'2`
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:
std::ops::DerefMut<Target = T>,
for<'a, 'b> <&'a mut ViewMut<'b, T> as IntoIter>::IntoIter: Iterator + LastId,
{
for (id, mut x) in WithId((&mut v).iter()) {
x.mutmut();
}
} And turns out the code in the issue you linked has the same issue. So I'm not sure it ever worked 😰 In theory something like this should also work: 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:
std::ops::DerefMut<Target = T>,
// binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types
// binding for associated type `Item` references lifetime `'b`, which does not appear in the trait input types
for<'a, 'b> WithId<<&'a mut ViewMut<'b, T> as IntoIter>::IntoIter>: Iterator<
Item = (
EntityId,
<<&'a mut ViewMut<'b, T> as IntoIter>::IntoIter as Iterator>::Item,
),
>,
{
for (id, mut x) in (&mut v).iter().with_id() {
x.mutmut();
}
} But it triggers this issue rust-lang/rust#49601. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#157 use some bounds to make generic ViewMut iterator work, but I still can not make generic ViewMut with_id work:
I try to add bounds but I still can not make it work.
Please help me, thanks!
The text was updated successfully, but these errors were encountered: