pub trait _IterTrait<'a, T>where
T: 'a,
Self: Iterator<Item = T> + ExactSizeIterator<Item = T> + DoubleEndedIterator + CloneDyn,{ }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> + 'c>
Available on crate feature iter_trait and (non-crate feature no_std or crate feature use_alloc) only.Implement Clone for boxed _IterTrait trait objects.
impl<'c, T> Clone for Box<dyn _IterTrait<'c, T> + 'c>
Available on crate feature
iter_trait and (non-crate feature no_std or crate feature use_alloc) only.Implement Clone for boxed _IterTrait trait objects.
This allows cloning of boxed iterators that implement _IterTrait.
Source§impl<'c, T> Clone for Box<dyn _IterTrait<'c, T> + Send + 'c>
Available on crate feature iter_trait and (non-crate feature no_std or crate feature use_alloc) only.
impl<'c, T> Clone for Box<dyn _IterTrait<'c, T> + Send + 'c>
Available on crate feature
iter_trait and (non-crate feature no_std or crate feature use_alloc) only.Source§impl<'c, T> Clone for Box<dyn _IterTrait<'c, T> + Send + Sync + 'c>
Available on crate feature iter_trait and (non-crate feature no_std or crate feature use_alloc) only.
impl<'c, T> Clone for Box<dyn _IterTrait<'c, T> + Send + Sync + 'c>
Available on crate feature
iter_trait and (non-crate feature no_std or crate feature use_alloc) only.Implementors§
impl<'a, T, I> _IterTrait<'a, T> for Iwhere
T: 'a,
Self: Iterator<Item = T> + ExactSizeIterator<Item = T> + DoubleEndedIterator + CloneDyn,
Available on crate feature
iter_trait only.