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]

[src]

Try to alloc on stack, and return Err when val is larger than capacity

Examples

use smallbox::StackBox;

assert!(StackBox::<[usize]>::new([0usize; 1]).is_ok());
assert!(StackBox::<[usize]>::new([0usize; 8]).is_err());

[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]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<T: ?Sized, Space> DerefMut for StackBox<T, Space>
[src]

[src]

Mutably dereferences the value.

impl<T: ?Sized, Space> Drop for StackBox<T, Space>
[src]

[src]

Executes the destructor for this type. Read more

impl<T: Display + ?Sized, Space> Display for StackBox<T, Space>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Debug + ?Sized, Space> Debug for StackBox<T, Space>
[src]

[src]

Formats the value using the given formatter.

impl<T: ?Sized, Space> Pointer for StackBox<T, Space>
[src]

[src]

Formats the value using the given formatter.

impl<T: ?Sized + PartialEq, Space> PartialEq for StackBox<T, Space>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: ?Sized + PartialOrd, Space> PartialOrd for StackBox<T, Space>
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

[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]

[src]

This method returns an Ordering between self and other. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl<T: ?Sized + Eq, Space> Eq for StackBox<T, Space>
[src]

impl<T: ?Sized + Hash, Space> Hash for StackBox<T, Space>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more