pub struct EnumTableBuilder<K: Enumable, V, const N: usize> { /* private fields */ }Expand description
A builder for creating an EnumTable with a specified number of elements.
EnumTableBuilder allows for the incremental construction of an EnumTable
by pushing elements one by one and then building the final table.
Implementations§
Source§impl<K: Enumable, V, const N: usize> EnumTableBuilder<K, V, N>
impl<K: Enumable, V, const N: usize> EnumTableBuilder<K, V, N>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new EnumTableBuilder with an uninitialized table.
§Returns
A new instance of EnumTableBuilder.
Sourcepub const fn push(&mut self, variant: &K, value: V)
pub const fn push(&mut self, variant: &K, value: V)
Pushes a new element into the builder.
§Arguments
variant- A reference to an enumeration variant.value- The value to associate with the variant.
Sourcepub const fn build(self) -> [(Discriminant<K>, V); N]
pub const fn build(self) -> [(Discriminant<K>, V); N]
Builds the table from the pushed elements.
§Returns
An array of tuples where each tuple contains a discriminant of an enumeration variant and its associated value.
Sourcepub const fn build_to(self) -> EnumTable<K, V, N>
pub const fn build_to(self) -> EnumTable<K, V, N>
Builds the EnumTable from the pushed elements.
§Returns
An EnumTable containing the elements pushed into the builder.
Trait Implementations§
Auto Trait Implementations§
impl<K, V, const N: usize> Freeze for EnumTableBuilder<K, V, N>
impl<K, V, const N: usize> RefUnwindSafe for EnumTableBuilder<K, V, N>
impl<K, V, const N: usize> Send for EnumTableBuilder<K, V, N>where
V: Send,
impl<K, V, const N: usize> Sync for EnumTableBuilder<K, V, N>where
V: Sync,
impl<K, V, const N: usize> Unpin for EnumTableBuilder<K, V, N>where
V: Unpin,
impl<K, V, const N: usize> UnwindSafe for EnumTableBuilder<K, V, 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