Skip to content

How to use generic ViewMut with_id? #191

@SSSxCCC

Description

@SSSxCCC

#157 use some bounds to make generic ViewMut iterator work, but I still can not make generic ViewMut with_id work:

trait MutTrait {
    fn mutmut(&mut self);
}

fn expected<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 mut x in (&mut v).iter() {
        x.mutmut();
    }
}

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 shipyard::IntoIter>::IntoIter: IntoWithId,
    for<'a, 'b> WithId<<&'a mut ViewMut<'b, T> as shipyard::IntoIter>::IntoIter>: Iterator,
    for<'a, 'b> <WithId<<&'a mut ViewMut<'b, T> as shipyard::IntoIter>::IntoIter> as Iterator>::Item: std::ops::DerefMut<Target = (EntityId, dyn std::ops::DerefMut<Target = T>)>
{
    for (id, x) in (&mut v).iter().with_id() { // error: expected associated type, found `(_, _)`
        x.mutmut();
    }
}

I try to add bounds but I still can not make it work.
Please help me, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions