Skip to main content

KeyedRoster

Struct KeyedRoster 

Source
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>

Source

pub const fn one(member: T, key: K) -> Self

A roster containing one member under its caller-declared key.

Source

pub const fn first(&self) -> &T

The first member, which this roster always has.

Source

pub const fn first_key(&self) -> &K

The key retained for the first member.

Source

pub fn count(&self) -> usize

How many members are held, which is never zero.

Source

pub fn members(&self) -> impl Iterator<Item = &T>

Reads the members in declaration order.

Source

pub fn keys(&self) -> impl Iterator<Item = &K>

Reads the retained keys in declaration order.

Source

pub fn indexed(&self) -> impl Iterator<Item = (usize, &K, &T)>

Reads every declaration index, retained key, and member together.

Source

pub fn at(&self, index: usize) -> Option<(&K, &T)>

Reads the key and member at one checked declaration index.

Source

pub fn index_of<Q>(&self, sought: &Q) -> Option<usize>
where K: Borrow<Q>, Q: Eq + ?Sized,

Finds the declaration index of one borrowed key.

Source

pub fn get<Q>(&self, sought: &Q) -> Option<&T>
where K: Borrow<Q>, Q: Eq + ?Sized,

Finds the member held under one borrowed key.

Source

pub fn indexed_get<Q>(&self, sought: &Q) -> Option<(usize, &K, &T)>
where K: Borrow<Q>, Q: Eq + ?Sized,

Finds the declaration position, retained key, and member under one borrowed key.

Source§

impl<T, K: Eq, const N: usize> KeyedRoster<T, K, N>

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, K: Debug, const N: usize> Debug for KeyedRoster<T, K, N>

Source§

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

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

impl<T: Eq, K: Eq, const N: usize> Eq for KeyedRoster<T, K, N>

Source§

impl<T: Hash, K: Hash, const N: usize> Hash for KeyedRoster<T, K, N>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq, K: PartialEq, const N: usize> PartialEq for KeyedRoster<T, K, N>

Source§

fn eq(&self, other: &KeyedRoster<T, K, N>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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>
where NonEmpty<T, N>: Freeze, NonEmpty<K, N>: Freeze,

§

impl<T, K, const N: usize> RefUnwindSafe for KeyedRoster<T, K, N>

§

impl<T, K, const N: usize> Send for KeyedRoster<T, K, N>
where NonEmpty<T, N>: Send, NonEmpty<K, N>: Send,

§

impl<T, K, const N: usize> Sync for KeyedRoster<T, K, N>
where NonEmpty<T, N>: Sync, NonEmpty<K, N>: Sync,

§

impl<T, K, const N: usize> Unpin for KeyedRoster<T, K, N>
where NonEmpty<T, N>: Unpin, NonEmpty<K, N>: Unpin,

§

impl<T, K, const N: usize> UnsafeUnpin for KeyedRoster<T, K, N>

§

impl<T, K, const N: usize> UnwindSafe for KeyedRoster<T, K, N>
where NonEmpty<T, N>: UnwindSafe, NonEmpty<K, N>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.