pub struct FrozenVec<T> { /* private fields */ }
Expand description
Append-only threadsafe version of std::vec::Vec
where
insertion does not require mutable access
Implementations§
source§impl<T: StableDeref> FrozenVec<T>
impl<T: StableDeref> FrozenVec<T>
pub fn new() -> Self
pub fn push(&self, val: T)
sourcepub fn push_get(&self, val: T) -> &T::Target
pub fn push_get(&self, val: T) -> &T::Target
Push, immediately getting a reference to the element
sourcepub fn push_get_index(&self, val: T) -> usize
pub fn push_get_index(&self, val: T) -> usize
Push, immediately getting a an index of the element
Index can then be used with the get
method
Examples
use elsa::sync::FrozenVec;
let map = FrozenVec::new();
let idx = map.push_get_index(String::from("a"));
assert_eq!(map.get(idx), Some("a"));
assert_eq!(idx, 0);
assert_eq!(map.push_get_index(String::from("b")), 1);
pub fn get(&self, index: usize) -> Option<&T::Target>
Trait Implementations§
source§impl<'a, T: StableDeref> IntoIterator for &'a FrozenVec<T>
impl<'a, T: StableDeref> IntoIterator for &'a FrozenVec<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for FrozenVec<T>
impl<T> Send for FrozenVec<T>where T: Send,
impl<T> Sync for FrozenVec<T>where T: Send + Sync,
impl<T> Unpin for FrozenVec<T>where T: Unpin,
impl<T> UnwindSafe for FrozenVec<T>
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