pub struct KeyedRoster<T, K, const N: usize> { /* private fields */ }Expand description
A non-empty bounded roster whose caller-declared keys are unique.
Implementations§
Source§impl<T, K, const N: usize> KeyedRoster<T, K, N>
impl<T, K, const N: usize> KeyedRoster<T, K, N>
Sourcepub const fn one(member: T, key: K) -> Self
pub const fn one(member: T, key: K) -> Self
A roster containing one member under its caller-declared key.
Sourcepub fn indexed(&self) -> impl Iterator<Item = (usize, &K, &T)>
pub fn indexed(&self) -> impl Iterator<Item = (usize, &K, &T)>
Reads every declaration index, retained key, and member together.
Sourcepub fn at(&self, index: usize) -> Option<(&K, &T)>
pub fn at(&self, index: usize) -> Option<(&K, &T)>
Reads the key and member at one checked declaration index.
Sourcepub fn index_of<Q>(&self, sought: &Q) -> Option<usize>
pub fn index_of<Q>(&self, sought: &Q) -> Option<usize>
Finds the declaration index of one borrowed key.
Source§impl<T, K: Eq, const N: usize> KeyedRoster<T, K, N>
impl<T, K: Eq, const N: usize> KeyedRoster<T, K, N>
Sourcepub fn new(
members: Vec<T>,
key_of: impl FnMut(&T) -> K,
) -> Result<Self, KeyedRosterError<K, N>>
pub fn new( members: Vec<T>, key_of: impl FnMut(&T) -> K, ) -> Result<Self, KeyedRosterError<K, N>>
Admits one complete ordered offering under caller-declared unique keys.
The offering’s nonempty bounded magnitude is settled before the key projection runs.
§Errors
Returns Empty when nothing is offered, Overflow when more than N items are offered, and DuplicateKey coordinates for every distinct key that occurs more than once.
Trait Implementations§
Source§impl<T: Clone, K: Clone, const N: usize> Clone for KeyedRoster<T, K, N>
impl<T: Clone, K: Clone, const N: usize> Clone for KeyedRoster<T, K, N>
Source§fn clone(&self) -> KeyedRoster<T, K, N>
fn clone(&self) -> KeyedRoster<T, K, N>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T: Eq, K: Eq, const N: usize> Eq for KeyedRoster<T, K, N>
impl<T: PartialEq, K: PartialEq, const N: usize> StructuralPartialEq for KeyedRoster<T, K, N>
Auto Trait Implementations§
impl<T, K, const N: usize> Freeze for KeyedRoster<T, K, N>
impl<T, K, const N: usize> RefUnwindSafe for KeyedRoster<T, K, N>
impl<T, K, const N: usize> Send for KeyedRoster<T, K, N>
impl<T, K, const N: usize> Sync for KeyedRoster<T, K, N>
impl<T, K, const N: usize> Unpin for KeyedRoster<T, K, N>
impl<T, K, const N: usize> UnsafeUnpin for KeyedRoster<T, K, N>
impl<T, K, const N: usize> UnwindSafe for KeyedRoster<T, K, N>
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