[−][src]Crate scoped_vec
A library for scoped Vec
s, allowing multi-level divergence from
the root element.
This is useful for monitoring state within a de facto tree where links to parents aren't necessarily needed. Consumers can keep references to a specific parent if required and check the values from the scope of their choosing, parents are free to be dropped if they're no longer required.
The full std::vec::Vec spec has not yet been implemented but as
the library stabilises, more and more of the Vec
library will be
supported - however there will be some divergence from the API where
necessary given the structural differences of a ScopedVec
.
Example:
let mut root = ScopedVec::new(); root.push(3); { let mut scope1 = root.scope(); scope1.push(4); { let mut scope1_scope1 = scope1.scope(); scope1_scope1.push(5); } let mut iter = scope1.iter(); assert_eq!(iter.next(), Some(&4)); assert_eq!(iter.next(), Some(&5)); assert_eq!(iter.next(), None); } { let mut scope2 = root.scope(); scope2.push(6); } let mut iter = root.iter(); assert_eq!(iter.next(), Some(&3)); assert_eq!(iter.next(), Some(&4)); assert_eq!(iter.next(), Some(&5)); assert_eq!(iter.next(), Some(&6)); assert_eq!(iter.next(), None);
Structs
ScopedVec | A |
ScopedVecGuardHolder | |
ScopedVecIterator |