_IterTrait

Trait _IterTrait 

Source
pub trait _IterTrait<'a, T>:
    Iterator<Item = T, Item = T>
    + ExactSizeIterator
    + DoubleEndedIterator
    + CloneDyn
where T: 'a,
{ }
Expand description

Trait that encapsulates an iterator with specific characteristics and implemetning CloneDyn.

The _IterTrait trait is designed to represent iterators that may yield references to items ( &'a T ). These iterators must also implement the ExactSizeIterator and DoubleEndedIterator traits. This combination ensures that the iterator can:

  • Provide an exact size hint ( ExactSizeIterator ),
  • Be traversed from both ends ( DoubleEndedIterator ).

Additionally, the iterator must implement the CloneDyn trait, which allows cloning of trait objects.

§Example

use iter_tools::_IterTrait;

// Example struct that implements Iterator, ExactSizeIterator, DoubleEndedIterator, and CloneDyn.
#[ derive( Clone ) ]
struct MyIterator
{
  // internal fields
}

impl Iterator for MyIterator
{
  type Item = i32;

  fn next( &mut self ) -> Option<  Self::Item  >
  {
    // implementation
    Some( 1 )
  }
}

impl ExactSizeIterator for MyIterator
{
  fn len( &self ) -> usize
  {
    // implementation
    1
  }
}

impl DoubleEndedIterator for MyIterator
{
  fn next_back( &mut self ) -> Option<  Self::Item  >
  {
    // implementation
    Some( 1 )
  }
}

Trait Implementations§

Source§

impl<'c, T> Clone for Box<dyn _IterTrait<'c, T, Item = T> + 'c>

Implement Clone for boxed _IterTrait trait objects.

This allows cloning of boxed iterators that implement _IterTrait.

Source§

fn clone(&self) -> Box<dyn _IterTrait<'c, T, Item = T> + 'c>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'c, T> Clone for Box<dyn _IterTrait<'c, T, Item = T> + Send + 'c>

Source§

fn clone(&self) -> Box<dyn _IterTrait<'c, T, Item = T> + Send + 'c>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'c, T> Clone for Box<dyn _IterTrait<'c, T, Item = T> + Send + Sync + 'c>

Source§

fn clone(&self) -> Box<dyn _IterTrait<'c, T, Item = T> + Send + Sync + 'c>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'c, T> Clone for Box<dyn _IterTrait<'c, T, Item = T> + Sync + 'c>

Source§

fn clone(&self) -> Box<dyn _IterTrait<'c, T, Item = T> + Sync + 'c>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§

Source§

impl<'a, T, I> _IterTrait<'a, T> for I
where T: 'a, I: Iterator<Item = T, Item = T> + ExactSizeIterator + DoubleEndedIterator + CloneDyn,