pub trait LendingIterator: for<'a> Lifetime<'a> {
    // Required method
    fn next(&mut self) -> Option<<Self as Lifetime<'_>>::Item>;

    // Provided method
    fn for_each<F>(self, f: F)
       where Self: Sized,
             F: FnMut(<Self as Lifetime<'_>>::Item) { ... }
}

Required Methods§

source

fn next(&mut self) -> Option<<Self as Lifetime<'_>>::Item>

Provided Methods§

source

fn for_each<F>(self, f: F)where Self: Sized, F: FnMut(<Self as Lifetime<'_>>::Item),

Examples found in repository?
examples/basic.rs (lines 37-39)
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
fn main() {
    let mut world = world::World::<Storage>::new();

    checs::spawn!(world, Health(80), Position { x: 0, y: 0 }, Visible);
    checs::spawn!(world, Position { x: 1, y: 1 }, Visible);
    checs::spawn!(world, Position { x: 2, y: 1 });
    checs::spawn!(world, Health(100), Position { x: 1, y: 4 }, Visible);


    {
        let ps = &world.storage.positions;
        let hs = &mut world.storage.healths;
        let vs = &world.storage.visibles;

        let query = (ps, hs, vs).into_query();

        query.for_each(|(_, (_, h, _))| {
            h.0 += 10;
        });
    }

    println!();

    {
        let ps = &world.storage.positions;
        let hs = &world.storage.healths;
        let vs = &world.storage.visibles;

        let query = (ps, hs, vs).into_query();

        query.for_each(|(e, (p, h, v))| {
            println!("{e:?} is {v:?} at ({}, {}) with {} HP", p.x, p.y, h.0);
        });
    }
}

Implementors§

source§

impl<'a, Iter, A, B, C, D, E, F, G> LendingIterator for Query<Iter, (A, B, C, D, E, F, G)>where Iter: Iterator<Item = Entity>, A: GetRefOrMut<'a>, B: GetRefOrMut<'a>, C: GetRefOrMut<'a>, D: GetRefOrMut<'a>, E: GetRefOrMut<'a>, F: GetRefOrMut<'a>, G: GetRefOrMut<'a>,

source§

impl<'a, Iter, B, C, D, E, F, G> LendingIterator for Query<Iter, (B, C, D, E, F, G)>where Iter: Iterator<Item = Entity>, B: GetRefOrMut<'a>, C: GetRefOrMut<'a>, D: GetRefOrMut<'a>, E: GetRefOrMut<'a>, F: GetRefOrMut<'a>, G: GetRefOrMut<'a>,

source§

impl<'a, Iter, C, D, E, F, G> LendingIterator for Query<Iter, (C, D, E, F, G)>where Iter: Iterator<Item = Entity>, C: GetRefOrMut<'a>, D: GetRefOrMut<'a>, E: GetRefOrMut<'a>, F: GetRefOrMut<'a>, G: GetRefOrMut<'a>,

source§

impl<'a, Iter, D, E, F, G> LendingIterator for Query<Iter, (D, E, F, G)>where Iter: Iterator<Item = Entity>, D: GetRefOrMut<'a>, E: GetRefOrMut<'a>, F: GetRefOrMut<'a>, G: GetRefOrMut<'a>,

source§

impl<'a, Iter, E, F, G> LendingIterator for Query<Iter, (E, F, G)>where Iter: Iterator<Item = Entity>, E: GetRefOrMut<'a>, F: GetRefOrMut<'a>, G: GetRefOrMut<'a>,

source§

impl<'a, Iter, F, G> LendingIterator for Query<Iter, (F, G)>where Iter: Iterator<Item = Entity>, F: GetRefOrMut<'a>, G: GetRefOrMut<'a>,

source§

impl<I> LendingIterator for Iwhere I: Iterator,