pub struct AutoVec<T> { /* private fields */ }Expand description
Example
use auto_vec::*;
fn main() {
let mut t1 = AutoChild::new(0);
let mut t2 = AutoChild::new(1);
let mut v = AutoVec::new();
v.add(&mut t1);
v.add(&mut t2);
for i in &mut v {
*i = 3;
}
println!("{:?}", v);
}Implementations§
source§impl<T> AutoVec<T>
impl<T> AutoVec<T>
sourcepub fn new() -> Pin<Box<Self>>
pub fn new() -> Pin<Box<Self>>
Note that the reterned type is not AutoVec itself, but std::pin::Pin<Box
It is required because, AutoChild contains a pointer to its container. If the container is not pinned, its address may change, leading to invalid pointer in AutoChild.
sourcepub fn append(&mut self, other: &mut AutoVec<T>)
pub fn append(&mut self, other: &mut AutoVec<T>)
Moves all the elements of other into self, leaving other empty.
See Vec::append() for more details.
sourcepub fn add(&mut self, child: &mut AutoChild<T>)
pub fn add(&mut self, child: &mut AutoChild<T>)
If the child is already in the vec, it will not be added a second time. A normal child cannot be added to multiple containers, adding it to another vec will remove it from the previous one.
sourcepub fn remove(&mut self, child: &mut AutoChild<T>)
pub fn remove(&mut self, child: &mut AutoChild<T>)
Using Vec::swap_remove()
pub fn clear(&mut self)
pub fn len(&self) -> usize
sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Reexport Vec::shrink_to()
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Reexport Vec::shrink_to_fit()
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
See Vec::with_capacity() for more details.