Struct auto_vec::AutoVec

source ·
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>

source

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.

source

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.

source

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.

source

pub fn remove(&mut self, child: &mut AutoChild<T>)

source

pub fn clear(&mut self)

source

pub fn len(&self) -> usize

source

pub fn shrink_to(&mut self, min_capacity: usize)

source

pub fn shrink_to_fit(&mut self)

source

pub fn with_capacity(capacity: usize) -> Self

See Vec::with_capacity() for more details.

source

pub fn iter_mut(&self) -> IterMut<'_, T>

source

pub fn iter(&self) -> Iter<'_, T>

Trait Implementations§

source§

impl<T: Debug> Debug for AutoVec<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Drop for AutoVec<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T> Index<usize> for AutoVec<T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<usize> for AutoVec<T>

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for AutoVec<T>where T: RefUnwindSafe,

§

impl<T> !Send for AutoVec<T>

§

impl<T> !Sync for AutoVec<T>

§

impl<T> Unpin for AutoVec<T>

§

impl<T> UnwindSafe for AutoVec<T>where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.