pub struct DVec<T> { /* private fields */ }Expand description
A persistent vector of T elements. Persistent collections
change the trade-off relative to ordinary collections: they are
very cheap to clone, but more expensive to update. Behind the
scenes, DVec instances that are cloned from one another will
share some part of their representation.
You may be accustomed to persistent APIs in other languages,
where each mutation operation returns a new collection instead of
modifying the collection in place. The DVec type, in contrast,
behaves roughly like an ordinary vector, except that you can cheaply
clone it. If you want to get a new collection with a given mutation,
but leave the existing collection alone, use clone:
let mut vec1 = DVec::new();
vec1.push(22);
let mut vec2 = vec1.clone();
vec2.push(44);
assert_eq!(vec1.len(), 1);
assert_eq!(vec2.len(), 2);Implementations§
Trait Implementations§
Source§impl<T: Ord> Ord for DVec<T>
impl<T: Ord> Ord for DVec<T>
Source§impl<T: PartialOrd> PartialOrd for DVec<T>
impl<T: PartialOrd> PartialOrd for DVec<T>
impl<T: Eq> Eq for DVec<T>
impl<T> StructuralPartialEq for DVec<T>
Auto Trait Implementations§
impl<T> Freeze for DVec<T>
impl<T> RefUnwindSafe for DVec<T>where
T: RefUnwindSafe,
impl<T> Send for DVec<T>
impl<T> Sync for DVec<T>
impl<T> Unpin for DVec<T>where
T: Unpin,
impl<T> UnwindSafe for DVec<T>where
T: UnwindSafe + RefUnwindSafe,
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