Trait LendingIterator

Source
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).

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 LendingIterator for AggregateIterator<'_>

Source§

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

Source§

impl LendingIterator for ColumnIterator<'_>

Source§

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

Source§

impl LendingIterator for FieldIterator<'_>

Source§

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

Source§

impl LendingIterator for FunctionIterator<'_>

Source§

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

Source§

impl LendingIterator for KeyspaceIterator<'_>

Source§

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

Source§

impl LendingIterator for MapIterator<'_>

Source§

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

Source§

impl LendingIterator for SetIterator<'_>

Source§

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

Source§

impl LendingIterator for TableIterator<'_>

Source§

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

Source§

impl LendingIterator for UserTypeIterator<'_>

Source§

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