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> + Sized,
[src]
U: Unsize<T> + Sized,
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>
[src]
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 + Unsize<U>, U: ?Sized> CoerceUnsized<StackBox<U>> for StackBox<T>
[src]
impl<T: ?Sized, Space> Deref for StackBox<T, Space>
[src]
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
Dereferences the value.
impl<T: ?Sized, Space> DerefMut for StackBox<T, Space>
[src]
impl<T: ?Sized, Space> Drop for StackBox<T, Space>
[src]
impl<T: Display + ?Sized, Space> Display for StackBox<T, Space>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
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
[src]
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
[src]
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>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &StackBox<T, Space>) -> bool
[src]
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
[src]
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
[src]
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
[src]
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
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
[src]
ord_max_min
)Compares and returns the minimum of two values. Read more