Struct smallbox::StackBox
[−]
[src]
pub struct StackBox<T: ?Sized, Space = S2> { /* fields omitted */ }
On-stack allocation for dynamically-sized type.
Examples
use smallbox::StackBox; let val: StackBox<PartialEq<usize>> = StackBox::new(5usize).unwrap(); assert!(*val == 5)
Methods
impl<T: ?Sized, Space> StackBox<T, Space>[src]
fn new<U>(val: U) -> Result<StackBox<T, Space>, U> where
U: Unsize<T>,
U: Unsize<T>,
Try to alloc on stack, and return Err
Examples
use smallbox::StackBox; assert!(StackBox::<[usize]>::new([0usize; 1]).is_ok()); assert!(StackBox::<[usize]>::new([0usize; 8]).is_err());
fn resize<ToSpace>(self) -> Result<StackBox<T, ToSpace>, Self>
Try to transforms to a StackBox<T> with bigger capacity,
and return Err when target capacity is smaller.
Example
use smallbox::StackBox; use smallbox::space::*; let s = StackBox::<[usize], S8>::new([0usize; 4]).unwrap(); assert!(s.resize::<S16>().is_ok()); let s = StackBox::<[usize], S8>::new([0usize; 4]).unwrap(); assert!(s.resize::<S4>().is_err());
Trait Implementations
impl<T: ?Sized, Space> Deref for StackBox<T, Space>[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T: ?Sized, Space> DerefMut for StackBox<T, Space>[src]
fn deref_mut(&mut self) -> &mut T
The method called to mutably dereference a value
impl<T: ?Sized, Space> Drop for StackBox<T, Space>[src]
impl<T: Display + ?Sized, Space> Display for StackBox<T, Space>[src]
impl<T: Debug + ?Sized, Space> Debug for StackBox<T, Space>[src]
impl<T: ?Sized, Space> Pointer for StackBox<T, Space>[src]
impl<T: ?Sized + PartialEq, Space> PartialEq for StackBox<T, Space>[src]
fn eq(&self, other: &StackBox<T, Space>) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &StackBox<T, Space>) -> bool
This method tests for !=.
impl<T: ?Sized + PartialOrd, Space> PartialOrd for StackBox<T, Space>[src]
fn partial_cmp(&self, other: &StackBox<T, Space>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &StackBox<T, Space>) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &StackBox<T, Space>) -> bool
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn ge(&self, other: &StackBox<T, Space>) -> bool
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
fn gt(&self, other: &StackBox<T, Space>) -> bool
This method tests greater than (for self and other) and is used by the > operator. Read more
impl<T: ?Sized + Ord, Space> Ord for StackBox<T, Space>[src]
fn cmp(&self, other: &StackBox<T, Space>) -> Ordering
This method returns an Ordering between self and other. Read more