IterElement

Struct IterElement 

Source
pub struct IterElement<R, T>
where R: RangeBounds<T>, T: Ord,
{ pub value: R, /* private fields */ }
Expand description

An element obtained from Iter.

This element allows access to its value, as well as providing an Iterator over all values nested within value through the sublist() method.

§Example

use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..2]);

let mut iter = nclist.into_iter();
assert_eq!(iter.next().unwrap().value, 1..2);

Fields§

§value: R

Implementations§

Source§

impl<R, T> IterElement<R, T>
where R: RangeBounds<T>, T: Ord,

Source

pub fn sublist(self) -> Iter<R, T>

Returns an Iter Iterator over this element’s sublist.

Note that this method consumes the IterElement.

§Example
use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..4, 2..3]);

let mut iter = nclist.into_iter();
let mut sublist = iter.next().unwrap().sublist();
assert_eq!(sublist.next().unwrap().value, 2..3);

Trait Implementations§

Source§

impl<R, T> Debug for IterElement<R, T>
where R: RangeBounds<T> + Debug, T: Ord + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R, T> IntoIterator for IterElement<R, T>
where R: RangeBounds<T>, T: Ord,

Source§

fn into_iter(self) -> Self::IntoIter

Returns an Iterator over this element’s value, followed by its sublist().

This is useful if you want to iterate over all values including the enclosing value.

§Example
use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..4, 2..3]);
let mut iter = nclist.into_iter();
let first_element = iter.next().unwrap();
let mut first_element_iter = first_element.into_iter();

assert_eq!(first_element_iter.next().unwrap().value, 1..4);
assert_eq!(first_element_iter.next().unwrap().value, 2..3);
Source§

type Item = IterElement<R, T>

The type of the elements being iterated over.
Source§

type IntoIter = Chain<Once<<IterElement<R, T> as IntoIterator>::Item>, Iter<R, T>>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

impl<R, T> Freeze for IterElement<R, T>
where R: Freeze,

§

impl<R, T> RefUnwindSafe for IterElement<R, T>

§

impl<R, T> Send for IterElement<R, T>
where R: Send, T: Send,

§

impl<R, T> Sync for IterElement<R, T>
where R: Sync, T: Sync,

§

impl<R, T> Unpin for IterElement<R, T>
where R: Unpin, T: Unpin,

§

impl<R, T> UnwindSafe for IterElement<R, T>
where R: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.