[][src]Struct dynstack::DynStack

pub struct DynStack<T: ?Sized> { /* fields omitted */ }

Methods

impl<T: ?Sized> DynStack<T>[src]

pub fn new() -> Self[src]

Creates a new, empty, DynStack.

Panics

Panics if T is not a trait object.

pub unsafe fn push(&mut self, item: *mut T)[src]

Push a trait object onto the stack.

This method is unsafe because in lieu of moving a trait object onto push's stack (not possible in rust as of 1.30.0) we copy it from the provided mutable pointer.

The user of this method must therefore either ensure that item has no Drop impl, or explicitly call std::mem::forget on item after pushing.

It is highly recommended to use the dyn_push macro instead of calling this directly.

pub fn remove_last(&mut self) -> bool[src]

Remove the last trait object from the stack. Returns true if any items were removed.

pub fn get<'a>(&'a self, index: usize) -> Option<&'a T>[src]

Retrieve a trait object reference at the provided index.

pub fn get_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut T>[src]

Retrieve a mutable trait object reference at the provided index.

pub fn peek<'a>(&'a self) -> Option<&'a T>[src]

Retrieve the trait object reference at the top of the stack.

pub fn peek_mut<'a>(&'a mut self) -> Option<&'a mut T>[src]

Retrieve the mutable trait object reference at the top of the stack.

pub fn len(&self) -> usize[src]

Returns the number of trait objects stored on the stack.

impl<'a, T: 'a + ?Sized> DynStack<T>[src]

Important traits for DynStackIter<'a, T>
pub fn iter(&'a self) -> DynStackIter<'a, T>[src]

Returns an iterator over trait object references

Important traits for DynStackIterMut<'a, T>
pub fn iter_mut(&'a mut self) -> DynStackIterMut<'a, T>[src]

Returns an iterator over mutable trait object references

Trait Implementations

impl<'a, T: 'a + ?Sized> IntoIterator for &'a DynStack<T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = DynStackIter<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T: 'a + ?Sized> IntoIterator for &'a mut DynStack<T>[src]

type Item = &'a mut T

The type of the elements being iterated over.

type IntoIter = DynStackIterMut<'a, T>

Which kind of iterator are we turning this into?

impl<T: ?Sized> Drop for DynStack<T>[src]

impl<T: ?Sized> Index<usize> for DynStack<T>[src]

type Output = T

The returned type after indexing.

impl<T: ?Sized> IndexMut<usize> for DynStack<T>[src]

Auto Trait Implementations

impl<T> !Send for DynStack<T>

impl<T> !Sync for DynStack<T>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.