pub struct NonEmpty<I: Iterator> { /* private fields */ }Expand description
An iterator source guaranteed to yield at least one item.
§Examples
use commonware_utils::iter::NonEmpty;
let items = NonEmpty::try_new([1, 2, 3].into_iter()).expect("items are non-empty");
assert_eq!(items.into_iter().collect::<Vec<_>>(), vec![1, 2, 3]);Implementations§
Source§impl<I: Iterator> NonEmpty<I>
impl<I: Iterator> NonEmpty<I>
Sourcepub const fn new(first: I::Item, rest: I) -> Self
pub const fn new(first: I::Item, rest: I) -> Self
Creates a non-empty iterator from a first item and the remaining items.
Sourcepub fn try_new(items: I) -> Option<Self>
pub fn try_new(items: I) -> Option<Self>
Creates a non-empty iterator from items, or returns None when it is empty.
Sourcepub fn into_parts(self) -> (I::Item, I)
pub fn into_parts(self) -> (I::Item, I)
Consumes this source, returning its first item and remaining iterator.
Trait Implementations§
Source§impl<I: Iterator> IntoIterator for NonEmpty<I>
impl<I: Iterator> IntoIterator for NonEmpty<I>
Auto Trait Implementations§
impl<I> Freeze for NonEmpty<I>
impl<I> RefUnwindSafe for NonEmpty<I>
impl<I> Send for NonEmpty<I>
impl<I> Sync for NonEmpty<I>
impl<I> Unpin for NonEmpty<I>
impl<I> UnsafeUnpin for NonEmpty<I>
impl<I> UnwindSafe for NonEmpty<I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more