pub struct DynStack<T: ?Sized> { /* private fields */ }
Implementations§
source§impl<T: ?Sized> DynStack<T>
impl<T: ?Sized> DynStack<T>
pub fn new() -> Self
sourcepub unsafe fn push(&mut self, item: *mut T)
pub unsafe fn push(&mut self, item: *mut T)
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.
sourcepub fn remove_last(&mut self) -> bool
pub fn remove_last(&mut self) -> bool
Remove the last trait object from the stack. Returns true if any items were removed.
sourcepub fn get<'a>(&'a self, index: usize) -> Option<&'a T>
pub fn get<'a>(&'a self, index: usize) -> Option<&'a T>
Retrieve a trait object reference at the provided index.
sourcepub fn get_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut T>
pub fn get_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut T>
Retrieve a mutable trait object reference at the provided index.
sourcepub fn peek<'a>(&'a self) -> Option<&'a T>
pub fn peek<'a>(&'a self) -> Option<&'a T>
Retrieve the trait object reference at the top of the stack.