Struct voluntary_servitude::VoluntaryServitude
source · pub struct VoluntaryServitude<T> { /* private fields */ }
Expand description
Lock-free appendable list (also called VS
)
Parallel examples in main lib docs
let list = vs![3, 2];
assert_eq!(list.len(), 2);
assert_eq!(list.iter().collect::<Vec<_>>(), vec![&3, &2]);
list.clear();
assert!(list.is_empty());
// You can deep copy a `VS` if T is Copy
use std::iter::FromIterator;
let list2 = VS::from_iter(list.iter());
list2.append(3);
assert_eq!(list.len() + 1, list2.len());
for el in list.iter() {
assert_eq!(el, &3);
}
Implementations
sourceimpl<T> VoluntaryServitude<T>
impl<T> VoluntaryServitude<T>
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Atomically extracts current size, be careful with data-races when using it
May grow or be set to 0
let list = vs![3, 2];
assert_eq!(list.len(), 2);
list.append(5);
assert_eq!(list.len(), 3);
list.clear();
assert_eq!(list.len(), 0);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Atomically checks if VS
is empty, be careful with data-races when using it
let list = vs![];
assert!(list.is_empty());
list.append(());
assert!(!list.is_empty());
sourcepub fn iter<'a>(&self) -> VSIter<'a, T> ⓘ
pub fn iter<'a>(&self) -> VSIter<'a, T> ⓘ
Makes lock-free iterator based on VoluntaryServitude
let list = vs![3, 2];
assert_eq!(list.iter().collect::<Vec<_>>(), vec![&3, &2]);
Trait Implementations
sourceimpl<T: Debug> Debug for VoluntaryServitude<T>
impl<T: Debug> Debug for VoluntaryServitude<T>
sourceimpl<T> Default for VoluntaryServitude<T>
impl<T> Default for VoluntaryServitude<T>
sourceimpl<'a, T: 'a + Deserialize<'a>> Deserialize<'a> for VoluntaryServitude<T>
impl<'a, T: 'a + Deserialize<'a>> Deserialize<'a> for VoluntaryServitude<T>
sourcefn deserialize<D: Deserializer<'a>>(des: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'a>>(des: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> Drop for VoluntaryServitude<T>
impl<T> Drop for VoluntaryServitude<T>
sourceimpl<'a, T: 'a + Copy> FromIterator<&'a T> for VoluntaryServitude<T>
impl<'a, T: 'a + Copy> FromIterator<&'a T> for VoluntaryServitude<T>
sourcefn from_iter<I: IntoIterator<Item = &'a T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = &'a T>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<T> FromIterator<T> for VoluntaryServitude<T>
impl<T> FromIterator<T> for VoluntaryServitude<T>
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<T: Hash> Hash for VoluntaryServitude<T>
impl<T: Hash> Hash for VoluntaryServitude<T>
sourceimpl<T: PartialEq> PartialEq<VoluntaryServitude<T>> for VoluntaryServitude<T>
impl<T: PartialEq> PartialEq<VoluntaryServitude<T>> for VoluntaryServitude<T>
sourceimpl<T: Serialize> Serialize for VoluntaryServitude<T>
Available on crate feature serde-traits
only.
impl<T: Serialize> Serialize for VoluntaryServitude<T>
Available on crate feature
serde-traits
only.impl<T: Eq> Eq for VoluntaryServitude<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for VoluntaryServitude<T>
impl<T> Send for VoluntaryServitude<T>
impl<T> Sync for VoluntaryServitude<T>
impl<T> Unpin for VoluntaryServitude<T>
impl<T> UnwindSafe for VoluntaryServitude<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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