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

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

    // Provided method
    fn size_hint(&self) -> (usize, Option<usize>) { ... }
}
Expand description

Iterator that only allows access to a single item at a time. You must stop using the returned item before getting the next.

Ultimately we will move to use a common crate for this, but to date there is no good crate to follow. https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#generic-associated-types-gats and https://github.com/Crazytieguy/gat-lending-iterator were references for this code.

The idiomatic way to work with this trait is as follows:

while let Some(row) = lending_iterator.next() {
  // ... do something with `row` ...
}

Required Associated Types§

source

type Item<'a> where Self: 'a

The type of each item.

Required Methods§

source

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

Retrieve the next item from the iterator; it lives only as long as the mutable reference to the iterator.

Provided Methods§

source

fn size_hint(&self) -> (usize, Option<usize>)

Minimum and optional maximum expected length of the iterator. Default implementation returns (0, None).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl LendingIterator for AggregateIterator<'_>

§

type Item<'a> = AggregateMeta<'a> where Self: 'a

source§

impl LendingIterator for ColumnIterator<'_>

§

type Item<'a> = ColumnMeta<'a> where Self: 'a

source§

impl LendingIterator for FieldIterator<'_>

§

type Item<'a> = Field<'a> where Self: 'a

source§

impl LendingIterator for FunctionIterator<'_>

§

type Item<'a> = FunctionMeta<'a> where Self: 'a

source§

impl LendingIterator for KeyspaceIterator<'_>

§

type Item<'a> = KeyspaceMeta<'a> where Self: 'a

source§

impl LendingIterator for MapIterator<'_>

§

type Item<'a> = (Value<'a>, Value<'a>) where Self: 'a

source§

impl LendingIterator for SetIterator<'_>

§

type Item<'a> = Value<'a> where Self: 'a

source§

impl LendingIterator for TableIterator<'_>

§

type Item<'a> = TableMeta<'a> where Self: 'a

source§

impl LendingIterator for UserTypeIterator<'_>

§

type Item<'a> = (String, Value<'a>) where Self: 'a