pub struct NonEmpty<T: ?Sized> { /* private fields */ }Expand description
A wrapper struct around non-empty slices/arrays/vectors.
You may wish to use the following type aliases instead:
See also crate documentation
Implementations§
Source§impl<const N: usize, T> NonEmpty<[T; N]>
Array methods
impl<const N: usize, T> NonEmpty<[T; N]>
Array methods
Sourcepub const unsafe fn new_ref_unchecked(src: &[T; N]) -> &Self
pub const unsafe fn new_ref_unchecked(src: &[T; N]) -> &Self
Sourcepub unsafe fn new_mut_unchecked(src: &mut [T; N]) -> &mut Self
pub unsafe fn new_mut_unchecked(src: &mut [T; N]) -> &mut Self
Sourcepub const unsafe fn new_unchecked(src: [T; N]) -> Self
pub const unsafe fn new_unchecked(src: [T; N]) -> Self
Sourcepub fn each_ref(&self) -> Array<&T, N>
pub fn each_ref(&self) -> Array<&T, N>
Borrows each element and returns a NonEmpty array of references with the same size as self.
Sourcepub fn each_mut(&mut self) -> Array<&mut T, N>
pub fn each_mut(&mut self) -> Array<&mut T, N>
Borrows each element mutably and returns a NonEmpty array of mutable references with the same size as self.
Sourcepub fn each_map<F, U>(self, f: F) -> Array<U, N>where
F: FnMut(T) -> U,
pub fn each_map<F, U>(self, f: F) -> Array<U, N>where
F: FnMut(T) -> U,
Returns a NonEmpty array of the same size as self, with function f applied to each element in order.
Sourcepub const fn as_slice_ne(&self) -> &Slice<T>
pub const fn as_slice_ne(&self) -> &Slice<T>
Returns a NonEmpty slice.
Sourcepub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
Returns a NonEmpty slice.
Sourcepub const fn as_array(&self) -> &[T; N]
pub const fn as_array(&self) -> &[T; N]
Returns a primitive array.
Sourcepub fn as_mut_array(&mut self) -> &mut [T; N]
pub fn as_mut_array(&mut self) -> &mut [T; N]
Returns a primitive array.
Sourcepub fn into_array(self) -> [T; N]
pub fn into_array(self) -> [T; N]
Returns a primitive array.
Source§impl<T, const N: usize> NonEmpty<[T; N]>
Known non-empty iterator for Array.
impl<T, const N: usize> NonEmpty<[T; N]>
Known non-empty iterator for Array.
pub fn into_iter_ne(self) -> NonEmpty<IntoIter<T, N>>
Source§impl<I> NonEmpty<I>where
I: Iterator,
Methods on Iterators with a non-empty invariant.
impl<I> NonEmpty<I>where
I: Iterator,
Methods on Iterators with a non-empty invariant.
See Self::relax to access the normal iterator inside.
Sourcepub fn first(self) -> I::Item
pub fn first(self) -> I::Item
NonEmpty version of Iterator::next.
let v = vec![1, 2, 3];
let _: Option<&u8> = v.iter().next();
// ^ normally you have to handle the empty case
let _: &u8 = v.iter_ne().first();
// ^ but we know there is at least one elementSourcepub fn last(self) -> I::Item
pub fn last(self) -> I::Item
NonEmpty version of Iterator::last.
let v = vec![1, 2, 3];
let _: Option<&u8> = v.iter().last();
// ^ normally you have to handle the empty case
let _: &u8 = v.iter_ne().last();
// ^ but we know there is at least one elementSourcepub fn map<B, F>(self, f: F) -> NonEmpty<Map<I, F>>
pub fn map<B, F>(self, f: F) -> NonEmpty<Map<I, F>>
NonEmpty version of Iterator::map.
let iter = slice![1, 2, 3].iter_ne();
assert_eq!(
iter.map(|it| *it * 2).last(),
// ^ the invariant is maintained
// so we _know_ there's a last element
6
);Sourcepub fn chain<U>(
self,
other: U,
) -> NonEmpty<Chain<I, <U as IntoIterator>::IntoIter>>where
U: IntoIterator<Item = I::Item>,
pub fn chain<U>(
self,
other: U,
) -> NonEmpty<Chain<I, <U as IntoIterator>::IntoIter>>where
U: IntoIterator<Item = I::Item>,
NonEmpty version of Iterator::chain.
let iter = slice![1, 2].iter_ne();
assert_eq!(
iter.chain(&[3]).last(),
// ^ the invariant is maintained
// so we _know_ there's a last element
&3
);Sourcepub fn enumerate(self) -> NonEmpty<Enumerate<I>>
pub fn enumerate(self) -> NonEmpty<Enumerate<I>>
NonEmpty version of Iterator::enumerate.
let iter = slice!['a', 'b'].iter_ne();
assert_eq!(
iter.enumerate().last(),
// ^ the invariant is maintained
// so we _know_ there's a last element
(1, &'b')
);Sourcepub fn peekable(self) -> NonEmpty<Peekable<I>>
pub fn peekable(self) -> NonEmpty<Peekable<I>>
NonEmpty version of Iterator::peekable, allowing you to use
Self::peek and Self::peek_mut
let mut peek_me = vec!['a', 'b'].into_iter_ne().peekable();
assert_eq!(
*peek_me.peek(),
'a'
);
*peek_me.peek_mut() = 'b';
assert_eq!(
peek_me.collect_vec(),
['b', 'b']
);Sourcepub fn take(self, n: NonZeroUsize) -> NonEmpty<Take<I>>
pub fn take(self, n: NonZeroUsize) -> NonEmpty<Take<I>>
NonEmpty version of Iterator::take.
Note that n cannot be zero, to maintain the NonEmpty invariant.
let iter = slice!['a', 'b'].iter_ne();
assert_eq!(
iter.take(nonzero!(1)).last(),
// ^ compile time checked
&'a'
)Sourcepub fn flatten<II, T>(self) -> NonEmpty<FlatMap<I, II, fn(I::Item) -> II>>
pub fn flatten<II, T>(self) -> NonEmpty<FlatMap<I, II, fn(I::Item) -> II>>
NonEmpty version of Iterator::flatten.
Note that the inner items must also be NonEmpty, to maintain the invariant.
use nunny::{vec};
let nested = vec![vec![1], vec![2, 3]];
assert_eq!(
nested.into_iter_ne().flatten().collect_vec(),
[1, 2, 3],
);Sourcepub fn inspect<F>(self, f: F) -> NonEmpty<Inspect<I, F>>
pub fn inspect<F>(self, f: F) -> NonEmpty<Inspect<I, F>>
NonEmpty version of Iterator::inspect.
Sourcepub fn reduce<F>(self, f: F) -> I::Item
pub fn reduce<F>(self, f: F) -> I::Item
NonEmpty version of Iterator::reduce.
let v = vec![1, 2, 3];
let _: Option<&u8> = v.iter().reduce(min);
// ^ normally you have to handle the empty case
let _: &u8 = v.iter_ne().reduce(min);
// ^ but we know there is at least one elementSourcepub fn max(self) -> I::Item
pub fn max(self) -> I::Item
NonEmpty version of Iterator::max.
let v = vec![1, 2, 3];
let _: Option<&u8> = v.iter().max();
// ^ normally you have to handle the empty case
let _: &u8 = v.iter_ne().max();
// ^ but we know there is at least one elementSourcepub fn min(self) -> I::Item
pub fn min(self) -> I::Item
NonEmpty version of Iterator::min.
let v = vec![1, 2, 3];
let _: Option<&u8> = v.iter().min();
// ^ normally you have to handle the empty case
let _: &u8 = v.iter_ne().min();
// ^ but we know there is at least one elementSourcepub fn max_by_key<B, F>(self, f: F) -> I::Item
pub fn max_by_key<B, F>(self, f: F) -> I::Item
NonEmpty version of Iterator::max_by_key.
Sourcepub fn max_by<F>(self, compare: F) -> I::Item
pub fn max_by<F>(self, compare: F) -> I::Item
NonEmpty version of Iterator::max_by.
Sourcepub fn min_by_key<B, F>(self, f: F) -> I::Item
pub fn min_by_key<B, F>(self, f: F) -> I::Item
NonEmpty version of Iterator::min_by_key.
Sourcepub fn min_by<F>(self, compare: F) -> I::Item
pub fn min_by<F>(self, compare: F) -> I::Item
NonEmpty version of Iterator::min_by.
Sourcepub fn rev(self) -> NonEmpty<Rev<I>>where
I: DoubleEndedIterator,
pub fn rev(self) -> NonEmpty<Rev<I>>where
I: DoubleEndedIterator,
NonEmpty version of Iterator::rev.
Sourcepub fn unzip_vec<A, B>(self) -> (Vec<A>, Vec<B>)
Available on crate feature alloc only.
pub fn unzip_vec<A, B>(self) -> (Vec<A>, Vec<B>)
alloc only.NonEmpty version of Iterator::unzip.
Sourcepub fn relax(self) -> I
pub fn relax(self) -> I
Remove the NonEmpty wrapper, allowing you to access normal iterator
methods like Iterator::filter.
Sourcepub fn collect_vec(self) -> Vec<I::Item>
Available on crate feature alloc only.
pub fn collect_vec(self) -> Vec<I::Item>
alloc only.Collect this iterator into a NonEmpty<Vec>.
Sourcepub fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
Available on crate feature alloc only.
pub fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
alloc only.Collect Ok items into a NonEmpty<Vec>, short-circuiting on Err.
Source§impl<I> NonEmpty<Peekable<I>>where
I: Iterator,
impl<I> NonEmpty<Peekable<I>>where
I: Iterator,
Sourcepub fn peek(&mut self) -> &I::Item
pub fn peek(&mut self) -> &I::Item
Peek this NonEmpty iterator, without advancing it.
See Self::peekable.
Sourcepub fn peek_mut(&mut self) -> &mut I::Item
pub fn peek_mut(&mut self) -> &mut I::Item
Peek and modify this NonEmpty iterator, without advancing it.
See Self::peekable.
Source§impl<T> NonEmpty<[T]>
Slice methods
impl<T> NonEmpty<[T]>
Slice methods
Sourcepub const unsafe fn new_unchecked(src: &[T]) -> &Self
pub const unsafe fn new_unchecked(src: &[T]) -> &Self
Sourcepub unsafe fn new_mut_unchecked(src: &mut [T]) -> &mut Self
pub unsafe fn new_mut_unchecked(src: &mut [T]) -> &mut Self
Sourcepub const fn as_slice(&self) -> &[T]
pub const fn as_slice(&self) -> &[T]
Returns a primitive slice.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Returns a primitive slice.
Sourcepub const fn len_ne(&self) -> NonZeroUsize
pub const fn len_ne(&self) -> NonZeroUsize
Returns the known non-zero length.
Sourcepub const fn split_first(&self) -> (&T, &[T])
pub const fn split_first(&self) -> (&T, &[T])
Returns the first element, guaranteed, and the rest of the elements.
Sourcepub const fn split_last(&self) -> (&T, &[T])
pub const fn split_last(&self) -> (&T, &[T])
Returns the last element, guaranteed, and the rest of the elements.
Sourcepub fn split_first_mut(&mut self) -> (&mut T, &mut [T])
pub fn split_first_mut(&mut self) -> (&mut T, &mut [T])
Returns the first element, guaranteed, and the rest of the elements.
Sourcepub fn split_last_mut(&mut self) -> (&mut T, &mut [T])
pub fn split_last_mut(&mut self) -> (&mut T, &mut [T])
Returns the last element, guaranteed, and the rest of the elements.
Source§impl<T> NonEmpty<Vec<T>>
Vec methods
impl<T> NonEmpty<Vec<T>>
Vec methods
Sourcepub unsafe fn new_unchecked(src: Vec<T>) -> Self
Available on crate feature alloc only.
pub unsafe fn new_unchecked(src: Vec<T>) -> Self
alloc only.Sourcepub unsafe fn new_ref_unchecked(src: &Vec<T>) -> &Self
Available on crate feature alloc only.
pub unsafe fn new_ref_unchecked(src: &Vec<T>) -> &Self
alloc only.Sourcepub unsafe fn new_mut_unchecked(src: &mut Vec<T>) -> &mut Self
Available on crate feature alloc only.
pub unsafe fn new_mut_unchecked(src: &mut Vec<T>) -> &mut Self
alloc only.Sourcepub fn new(src: Vec<T>) -> Result<Self, Vec<T>>
Available on crate feature alloc only.
pub fn new(src: Vec<T>) -> Result<Self, Vec<T>>
alloc only.Create a new NonEmpty heap-allocated vec, returning the original
allocation if it was empty.
Sourcepub fn of(item: T) -> Self
Available on crate feature alloc only.
pub fn of(item: T) -> Self
alloc only.Create a NonEmpty heap-allocated vec, of a single element.
Sourcepub fn of_with_capacity(item: T, capacity: usize) -> Self
Available on crate feature alloc only.
pub fn of_with_capacity(item: T, capacity: usize) -> Self
alloc only.Create a NonEmpty heap-allocated vec, of a single element, with
capacity for capacity elements without (re)-allocating.
Sourcepub fn of_extending<A>(first: T, rest: impl IntoIterator<Item = A>) -> Selfwhere
Self: Extend<A>,
Available on crate feature alloc only.
pub fn of_extending<A>(first: T, rest: impl IntoIterator<Item = A>) -> Selfwhere
Self: Extend<A>,
alloc only.Creating a NonEmpty heap-allocated vec where the first element is known.
This is an convenience method, equivalent to
let mut it = nunny::vec!["first"];
it.extend(["this", "is", "the", "rest"]);Sourcepub fn filled(value: T, len: NonZeroUsize) -> Selfwhere
T: Clone,
Available on crate feature alloc only.
pub fn filled(value: T, len: NonZeroUsize) -> Selfwhere
T: Clone,
alloc only.Create a NonEmpty heap-allocated vec with len items, filled with
Clones of the given value.
See also Self::filled_with.
Sourcepub fn filled_with<F>(f: F, len: NonZeroUsize) -> Selfwhere
F: FnMut() -> T,
Available on crate feature alloc only.
pub fn filled_with<F>(f: F, len: NonZeroUsize) -> Selfwhere
F: FnMut() -> T,
alloc only.Create a NonEmpty heap-allocated vec with len items, filled with
values returned from repeating the closure f.
See also Self::filled.
Sourcepub fn as_vec(&self) -> &Vec<T>
Available on crate feature alloc only.
pub fn as_vec(&self) -> &Vec<T>
alloc only.Returns a std::vec::Vec.
Sourcepub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>
Available on crate feature alloc only.
pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>
alloc only.Sourcepub fn into_vec(self) -> Vec<T>
Available on crate feature alloc only.
pub fn into_vec(self) -> Vec<T>
alloc only.Returns a std::vec::Vec.
Sourcepub fn as_slice_ne(&self) -> &Slice<T>
Available on crate feature alloc only.
pub fn as_slice_ne(&self) -> &Slice<T>
alloc only.Returns a NonEmpty slice.
Sourcepub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
Available on crate feature alloc only.
pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
alloc only.Returns a NonEmpty slice.
Sourcepub fn capacity(&self) -> NonZeroUsize
Available on crate feature alloc only.
pub fn capacity(&self) -> NonZeroUsize
alloc only.Returns the known non-zero length.
Sourcepub fn reserve(&mut self, additional: usize)
Available on crate feature alloc only.
pub fn reserve(&mut self, additional: usize)
alloc only.See reserve.
Sourcepub fn reserve_exact(&mut self, additional: usize)
Available on crate feature alloc only.
pub fn reserve_exact(&mut self, additional: usize)
alloc only.See reserve_exact.
Sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Available on crate feature alloc only.
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
alloc only.See try_reserve.
Sourcepub fn try_reserve_exact(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
Available on crate feature alloc only.
pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>
alloc only.See try_reserve_exact.
Sourcepub fn shrink_to_fit(&mut self)
Available on crate feature alloc only.
pub fn shrink_to_fit(&mut self)
alloc only.See shrink_to_fit.
Sourcepub fn shrink_to(&mut self, min_capacity: usize)
Available on crate feature alloc only.
pub fn shrink_to(&mut self, min_capacity: usize)
alloc only.See shrink_to.
Sourcepub fn into_boxed_slice(self) -> Box<Slice<T>>
Available on crate feature alloc only.
pub fn into_boxed_slice(self) -> Box<Slice<T>>
alloc only.Return a NonEmpty boxed slice.
Sourcepub fn truncate(&mut self, len: NonZeroUsize)
Available on crate feature alloc only.
pub fn truncate(&mut self, len: NonZeroUsize)
alloc only.Shortens the vector to a guaranteed-nonzero length
See truncate.
Sourcepub unsafe fn set_len(&mut self, new_len: NonZeroUsize)
Available on crate feature alloc only.
pub unsafe fn set_len(&mut self, new_len: NonZeroUsize)
alloc only.Sourcepub fn insert(&mut self, index: usize, element: T)
Available on crate feature alloc only.
pub fn insert(&mut self, index: usize, element: T)
alloc only.See insert.
Sourcepub fn dedup_by_key<F, K>(&mut self, key: F)
Available on crate feature alloc only.
pub fn dedup_by_key<F, K>(&mut self, key: F)
alloc only.See dedup_by_key.
Sourcepub fn dedup_by<F>(&mut self, same_bucket: F)
Available on crate feature alloc only.
pub fn dedup_by<F>(&mut self, same_bucket: F)
alloc only.See dedup_by.
Sourcepub fn resize_with<F>(&mut self, new_len: NonZeroUsize, f: F)where
F: FnMut() -> T,
Available on crate feature alloc only.
pub fn resize_with<F>(&mut self, new_len: NonZeroUsize, f: F)where
F: FnMut() -> T,
alloc only.See resize_with.
Sourcepub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]
Available on crate feature alloc only.
pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]
alloc only.See spare_capacity_mut.
Trait Implementations§
Source§impl<T, const N: usize> BorrowMut<NonEmpty<[T]>> for Array<T, N>
impl<T, const N: usize> BorrowMut<NonEmpty<[T]>> for Array<T, N>
Source§fn borrow_mut(&mut self) -> &mut Slice<T>
fn borrow_mut(&mut self) -> &mut Slice<T>
Source§impl<T> BorrowMut<NonEmpty<[T]>> for Vec<T>
Available on crate feature alloc only.
impl<T> BorrowMut<NonEmpty<[T]>> for Vec<T>
alloc only.Source§fn borrow_mut(&mut self) -> &mut Slice<T>
fn borrow_mut(&mut self) -> &mut Slice<T>
Source§impl<T> From<&NonEmpty<[T]>> for Arc<Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<T> From<&NonEmpty<[T]>> for Arc<Slice<T>>where
T: Clone,
alloc only.Source§impl<T> From<&NonEmpty<[T]>> for Box<Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<T> From<&NonEmpty<[T]>> for Box<Slice<T>>where
T: Clone,
alloc only.Source§impl<'a, T> From<&'a NonEmpty<[T]>> for Cow<'a, Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<'a, T> From<&'a NonEmpty<[T]>> for Cow<'a, Slice<T>>where
T: Clone,
alloc only.Source§impl<T> From<&NonEmpty<[T]>> for Rc<Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<T> From<&NonEmpty<[T]>> for Rc<Slice<T>>where
T: Clone,
alloc only.Source§impl<'a, const N: usize, T> From<&'a NonEmpty<[T; N]>> for Cow<'a, Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<'a, const N: usize, T> From<&'a NonEmpty<[T; N]>> for Cow<'a, Slice<T>>where
T: Clone,
alloc only.Source§impl<const N: usize, T> From<&NonEmpty<[T; N]>> for Vec<T>where
T: Clone,
Available on crate feature alloc only.
impl<const N: usize, T> From<&NonEmpty<[T; N]>> for Vec<T>where
T: Clone,
alloc only.Source§impl<'a, T> From<&'a NonEmpty<Vec<T>>> for Cow<'a, Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<'a, T> From<&'a NonEmpty<Vec<T>>> for Cow<'a, Slice<T>>where
T: Clone,
alloc only.Source§impl<T> From<&mut NonEmpty<[T]>> for Vec<T>where
T: Clone,
Available on crate feature alloc only.
impl<T> From<&mut NonEmpty<[T]>> for Vec<T>where
T: Clone,
alloc only.Source§impl<const N: usize, T> From<&mut NonEmpty<[T; N]>> for Vec<T>where
T: Clone,
Available on crate feature alloc only.
impl<const N: usize, T> From<&mut NonEmpty<[T; N]>> for Vec<T>where
T: Clone,
alloc only.Source§impl<const N: usize, K, V> From<NonEmpty<[(K, V); N]>> for BTreeMap<K, V>where
K: Ord,
Available on crate feature alloc only.
impl<const N: usize, K, V> From<NonEmpty<[(K, V); N]>> for BTreeMap<K, V>where
K: Ord,
alloc only.Source§impl<const N: usize, K, V> From<NonEmpty<[(K, V); N]>> for HashMap<K, V, RandomState>
Available on crate feature std only.
impl<const N: usize, K, V> From<NonEmpty<[(K, V); N]>> for HashMap<K, V, RandomState>
std only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for Arc<Slice<T>>
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for Arc<Slice<T>>
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for BTreeSet<T>where
T: Ord,
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for BTreeSet<T>where
T: Ord,
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for BinaryHeap<T>where
T: Ord,
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for BinaryHeap<T>where
T: Ord,
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for Box<Slice<T>>
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for Box<Slice<T>>
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for HashSet<T, RandomState>
Available on crate feature std only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for HashSet<T, RandomState>
std only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for LinkedList<T>
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for LinkedList<T>
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for Vec<T>
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for Vec<T>
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for Rc<Slice<T>>
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for Rc<Slice<T>>
alloc only.Source§impl<const N: usize, T> From<NonEmpty<[T; N]>> for VecDeque<T>
Available on crate feature alloc only.
impl<const N: usize, T> From<NonEmpty<[T; N]>> for VecDeque<T>
alloc only.Source§impl<'a, T> From<NonEmpty<Vec<T>>> for Cow<'a, Slice<T>>where
T: Clone,
Available on crate feature alloc only.
impl<'a, T> From<NonEmpty<Vec<T>>> for Cow<'a, Slice<T>>where
T: Clone,
alloc only.Source§impl<T, U> PartialEq<&NonEmpty<[U]>> for Cow<'_, Slice<T>>
Available on crate feature alloc only.
impl<T, U> PartialEq<&NonEmpty<[U]>> for Cow<'_, Slice<T>>
alloc only.Source§impl<T, U> PartialEq<&NonEmpty<[U]>> for Vec<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<&NonEmpty<[U]>> for Vec<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U> PartialEq<&NonEmpty<[U]>> for VecDeque<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<&NonEmpty<[U]>> for VecDeque<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<&NonEmpty<[U; N]>> for Vec<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<&NonEmpty<[U; N]>> for Vec<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<&NonEmpty<[U; N]>> for VecDeque<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<&NonEmpty<[U; N]>> for VecDeque<T>where
T: PartialEq<U>,
alloc only.Source§impl<A, B, const N: usize> PartialEq<&mut NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
impl<A, B, const N: usize> PartialEq<&mut NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
Source§impl<T, U> PartialEq<&mut NonEmpty<[U]>> for Cow<'_, Slice<T>>
Available on crate feature alloc only.
impl<T, U> PartialEq<&mut NonEmpty<[U]>> for Cow<'_, Slice<T>>
alloc only.Source§impl<T, U> PartialEq<&mut NonEmpty<[U]>> for Vec<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<&mut NonEmpty<[U]>> for Vec<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U> PartialEq<&mut NonEmpty<[U]>> for VecDeque<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<&mut NonEmpty<[U]>> for VecDeque<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<&mut NonEmpty<[U; N]>> for VecDeque<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<&mut NonEmpty<[U; N]>> for VecDeque<T>where
T: PartialEq<U>,
alloc only.Source§impl<A, B, const N: usize> PartialEq<NonEmpty<[A; N]>> for &mut Slice<B>where
B: PartialEq<A>,
impl<A, B, const N: usize> PartialEq<NonEmpty<[A; N]>> for &mut Slice<B>where
B: PartialEq<A>,
Source§impl<T, U> PartialEq<NonEmpty<[T]>> for Vec<U>where
U: PartialEq<T>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<[T]>> for Vec<U>where
U: PartialEq<T>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<NonEmpty<[T; N]>> for Vec<U>where
U: PartialEq<T>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<NonEmpty<[T; N]>> for Vec<U>where
U: PartialEq<T>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<[U]>> for Vec<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<[U]>> for Vec<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<NonEmpty<[U; N]>> for Vec<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<NonEmpty<[U; N]>> for Vec<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<NonEmpty<[U; N]>> for VecDeque<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<NonEmpty<[U; N]>> for VecDeque<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<T>>> for [U]where
U: PartialEq<T>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<T>>> for [U]where
U: PartialEq<T>,
alloc only.Source§impl<T, U, const N: usize> PartialEq<NonEmpty<Vec<T>>> for [U; N]where
U: PartialEq<T>,
Available on crate feature alloc only.
impl<T, U, const N: usize> PartialEq<NonEmpty<Vec<T>>> for [U; N]where
U: PartialEq<T>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<T>>> for Vec<U>where
U: PartialEq<T>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<T>>> for Vec<U>where
U: PartialEq<T>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<U>>> for &Slice<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<U>>> for &Slice<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<U>>> for &mut Slice<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<U>>> for &mut Slice<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<U>>> for Cow<'_, Slice<T>>
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<U>>> for Cow<'_, Slice<T>>
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<U>>> for Slice<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<U>>> for Slice<T>where
T: PartialEq<U>,
alloc only.Source§impl<T, U> PartialEq<NonEmpty<Vec<U>>> for Vec<T>where
T: PartialEq<U>,
Available on crate feature alloc only.
impl<T, U> PartialEq<NonEmpty<Vec<U>>> for Vec<T>where
T: PartialEq<U>,
alloc only.Source§impl<T> PartialOrd<NonEmpty<[T]>> for [T]where
T: PartialOrd,
impl<T> PartialOrd<NonEmpty<[T]>> for [T]where
T: PartialOrd,
Source§impl<T, const N: usize> PartialOrd<NonEmpty<[T]>> for [T; N]where
T: PartialOrd,
impl<T, const N: usize> PartialOrd<NonEmpty<[T]>> for [T; N]where
T: PartialOrd,
Source§impl<T> PartialOrd<NonEmpty<[T]>> for Vec<T>where
T: PartialOrd,
Available on crate feature alloc only.
impl<T> PartialOrd<NonEmpty<[T]>> for Vec<T>where
T: PartialOrd,
alloc only.Source§impl<T, const N: usize> PartialOrd<NonEmpty<[T; N]>> for [T]where
T: PartialOrd,
impl<T, const N: usize> PartialOrd<NonEmpty<[T; N]>> for [T]where
T: PartialOrd,
Source§impl<T, const N: usize> PartialOrd<NonEmpty<[T; N]>> for [T; N]where
T: PartialOrd,
impl<T, const N: usize> PartialOrd<NonEmpty<[T; N]>> for [T; N]where
T: PartialOrd,
Source§impl<T, const N: usize> PartialOrd<NonEmpty<[T; N]>> for Vec<T>where
T: PartialOrd,
Available on crate feature alloc only.
impl<T, const N: usize> PartialOrd<NonEmpty<[T; N]>> for Vec<T>where
T: PartialOrd,
alloc only.Source§impl<T> PartialOrd<NonEmpty<Vec<T>>> for [T]where
T: PartialOrd,
Available on crate feature alloc only.
impl<T> PartialOrd<NonEmpty<Vec<T>>> for [T]where
T: PartialOrd,
alloc only.Source§impl<T, const N: usize> PartialOrd<NonEmpty<Vec<T>>> for [T; N]where
T: PartialOrd,
Available on crate feature alloc only.
impl<T, const N: usize> PartialOrd<NonEmpty<Vec<T>>> for [T; N]where
T: PartialOrd,
alloc only.Source§impl<T> PartialOrd<NonEmpty<Vec<T>>> for Vec<T>where
T: PartialOrd,
Available on crate feature alloc only.
impl<T> PartialOrd<NonEmpty<Vec<T>>> for Vec<T>where
T: PartialOrd,
alloc only.Source§impl<T, const N: usize> TryFrom<NonEmpty<Vec<T>>> for Box<Array<T, N>>
Available on crate feature alloc only.
impl<T, const N: usize> TryFrom<NonEmpty<Vec<T>>> for Box<Array<T, N>>
alloc only.Source§impl<T, const N: usize> TryFrom<NonEmpty<Vec<T>>> for Array<T, N>
Available on crate feature alloc only.
impl<T, const N: usize> TryFrom<NonEmpty<Vec<T>>> for Array<T, N>
alloc only.impl<T: Copy + ?Sized> Copy for NonEmpty<T>
impl<T> Eq for NonEmpty<[T]>where
T: Eq,
impl<T, const N: usize> Eq for NonEmpty<[T; N]>where
T: Eq,
impl<T> Eq for NonEmpty<Vec<T>>where
T: Eq,
alloc only.Auto Trait Implementations§
impl<T> Freeze for NonEmpty<T>
impl<T> RefUnwindSafe for NonEmpty<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for NonEmpty<T>
impl<T> Sync for NonEmpty<T>
impl<T> Unpin for NonEmpty<T>
impl<T> UnwindSafe for NonEmpty<T>where
T: UnwindSafe + ?Sized,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random to avoid conflict with the new gen keyword in Rust 2024.Rng::random.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_rangeRng::random_range.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore to a RngReadAdapter.