pub struct Stacko<T, K: Key = DefaultKey> { /* private fields */ }
Expand description
A Stacko
for storing values of a single type.
Implementations
sourceimpl<T, K: Key> Stacko<T, K>
impl<T, K: Key> Stacko<T, K>
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs an empty Stacko
with a capacity of DEFAULT_CAPACITY
.
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructs an empty Stacko
able to store at least capacity values before
needing to allocate.
sourcepub fn push(&self, value: T) -> (K, &T)
pub fn push(&self, value: T) -> (K, &T)
Pushes a value onto the Stacko
potentially allocating more memory.
sourcepub fn get_mut(&mut self, key: K) -> Option<&mut T>
pub fn get_mut(&mut self, key: K) -> Option<&mut T>
Returns an exclusive reference to the value stored for the given key.
For details see get
.
sourcepub fn key_from_index(&self, index: usize) -> Option<K>
pub fn key_from_index(&self, index: usize) -> Option<K>
Returns a key corresponding to the provided index if a value is stored at the given index.
The complexity is O(log n).
Trait Implementations
sourceimpl<T, K: Key> FromIterator<T> for Stacko<T, K>
impl<T, K: Key> FromIterator<T> for Stacko<T, K>
sourcefn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<'p, T, K: Key> IntoIterator for &'p Stacko<T, K>
impl<'p, T, K: Key> IntoIterator for &'p Stacko<T, K>
Auto Trait Implementations
impl<T, K = DefaultKey> !RefUnwindSafe for Stacko<T, K>
impl<T, K> Send for Stacko<T, K> where
K: Send,
T: Send,
impl<T, K = DefaultKey> !Sync for Stacko<T, K>
impl<T, K> Unpin for Stacko<T, K> where
K: Unpin,
T: Unpin,
impl<T, K> UnwindSafe for Stacko<T, K> where
K: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more