Skip to main content

LendingIterator

Trait LendingIterator 

Source
pub trait LendingIterator {
    type Item<'this>
       where Self: 'this;

    // Required method
    fn next(&mut self) -> Option<Self::Item<'_>>;
}
Expand description

A minimal lending (streaming) iterator trait.

Unlike std::iter::Iterator, the item type may borrow from the iterator itself, enabling zero-allocation iteration where the inner buffer is reused across steps.

Use a while let loop to drive the iterator:

let mut iter = layer.iter_features();
while let Some(feat) = iter.next() {
    let feat = feat?;
    /* use feat here — it borrows from iter */
}

Required Associated Types§

Source

type Item<'this> where Self: 'this

The type of each element, which may borrow from self.

Required Methods§

Source

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

Advance the iterator, returning the next element or None when exhausted.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'layer> LendingIterator for Layer01FeatureIter<'layer, '_>

Source§

type Item<'this> = Result<FeatureRef<'this, 'layer>, MltError> where Self: 'this