devela::data::collections

Struct Stack

Source
pub struct Stack<T, const CAP: usize, IDX, S: Storage = Bare> { /* private fields */ }
Expand description

A static stack backed by an Array.

It is generic in respect to its elements (T), capacity (CAP), index size (IDX) and storage (S).

The index size will upper-bound the capacity to the maximum for that type, e.g. u8::MAX for StackU8.

The index size determines the maximum possible number of elements in the stack, thereby upper-bounding the capacity to the maximum value representable by the index type. For example, u8::MAX for StackU8.

The total size in bytes of the stack may be influenced by the chosen index size, depending on the size and alignment of the elements. This difference could only be significant for small capacities, as only one index is stored.

See also the related aliases that specify IDX: StackU8, StackU16, StackU32, StackUsize, and the DataStack trait.

§Methods

All the stack operations are done from the back.

The methods are the same for all IDX sizes:

The following list of methods links to the ones implemented for StackU8:

Implementations§

Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, u8, Bare>

§Stack resize.

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, u8, Bare>, IndexOutOfBounds>

Available on crate feature _stack_u8 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u8::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU8::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackU8::<_, 4> = s.resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackU8::<_, 12> = s.resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, u8, Bare>

Available on crate feature _stack_u8 only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackU8::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackU8::<_, 4> = s.resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackU8::<_, 12> = s.resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackU8::<_, 2> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, u8, Boxed>

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, u8, Boxed>, IndexOutOfBounds>

Available on crate features alloc and _stack_u8 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u8::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU8::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackU8::<_, 4, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackU8::<_, 12, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, u8, Boxed>

Available on crate features alloc and _stack_u8 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackU8::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackU8::<_, 4, Boxed> = s.clone().resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackU8::<_, 12, Boxed> = s.clone().resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackU8::<_, 2, Boxed> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: ConstDefault + Copy, const CAP: usize> Stack<T, CAP, u8, Bare>

Source

pub const fn own_resize_default<const NEW_CAP: usize>( self, ) -> Own<Result<Stack<T, NEW_CAP, u8, Bare>, IndexOutOfBounds>, ()>

Available on crate feature _stack_u8 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u8::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU8<i32, 8> = StackU8::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU8<i32, 4> = S.own_resize_default().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
let _ = S.own_resize_default::<2>().s_assert_err(); // too small
Source

pub const fn own_resize_default_truncate<const NEW_CAP: usize>( self, ) -> Own<Stack<T, NEW_CAP, u8, Bare>, ()>

Available on crate feature _stack_u8 only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
const S: StackU8<i32, 8> = StackU8::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU8<i32, 4> = S.own_resize_default_truncate().s;
assert_eq![S.as_slice(), T.as_slice()];
const U: StackU8<i32, 2> = S.own_resize_default_truncate().s;
assert_eq![U.as_slice(), &[2, 3]];
Source§

impl<T, const CAP: usize> Stack<T, CAP, u8, Bare>

§Stack index-size conversion.

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>

Available on crate feature _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackU8::<_, 6>::from([1, 2, 3, 4]);
let t: StackU8::<_, 6> = s.to_idx_u8().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>

Available on crate features _stack_u8 and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackU8::<_, 6>::from([1, 2, 3, 4]);
let t: StackU16::<_, 6> = s.to_idx_u16().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>

Available on crate features _stack_u8 and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackU8::<_, 6>::from([1, 2, 3, 4]);
let t: StackU32::<_, 6> = s.to_idx_u32().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>

Available on crate features _stack_u8 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackU8::<_, 6>::from([1, 2, 3, 4]);
let t: StackUsize::<_, 6> = s.to_idx_usize().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source§

impl<T, const CAP: usize> Stack<T, CAP, u8, Boxed>

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackU8::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU8::<_, 6, Boxed> = s.to_idx_u8().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u8 and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackU8::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU16::<_, 6, Boxed> = s.to_idx_u16().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u8 and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackU8::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU32::<_, 6, Boxed> = s.to_idx_u32().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u8 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackU8::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackUsize::<_, 6, Boxed> = s.to_idx_usize().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u8, Bare>

Source

pub const fn own_to_idx_u8( self, ) -> Own<Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>, ()>

Available on crate feature _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
const S: StackU8<i32, 6> = StackU8::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU8<i32, 6> = S.own_to_idx_u8().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u16( self, ) -> Own<Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u8 and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
const S: StackU8<i32, 6> = StackU8::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU16<i32, 6> = S.own_to_idx_u16().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u32( self, ) -> Own<Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u8 and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
const S: StackU8<i32, 6> = StackU8::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU32<i32, 6> = S.own_to_idx_u32().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_usize( self, ) -> Own<Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u8 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
const S: StackU8<i32, 6> = StackU8::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackUsize<i32, 6> = S.own_to_idx_usize().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, u16, Bare>

§Stack resize.

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, u16, Bare>, IndexOutOfBounds>

Available on crate feature _stack_u16 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u16::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU16::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackU16::<_, 4> = s.resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackU16::<_, 12> = s.resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, u16, Bare>

Available on crate feature _stack_u16 only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackU16::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackU16::<_, 4> = s.resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackU16::<_, 12> = s.resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackU16::<_, 2> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, u16, Boxed>

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, u16, Boxed>, IndexOutOfBounds>

Available on crate features alloc and _stack_u16 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u16::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU16::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackU16::<_, 4, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackU16::<_, 12, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, u16, Boxed>

Available on crate features alloc and _stack_u16 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackU16::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackU16::<_, 4, Boxed> = s.clone().resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackU16::<_, 12, Boxed> = s.clone().resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackU16::<_, 2, Boxed> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: ConstDefault + Copy, const CAP: usize> Stack<T, CAP, u16, Bare>

Source

pub const fn own_resize_default<const NEW_CAP: usize>( self, ) -> Own<Result<Stack<T, NEW_CAP, u16, Bare>, IndexOutOfBounds>, ()>

Available on crate feature _stack_u16 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u16::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU16<i32, 8> = StackU16::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU16<i32, 4> = S.own_resize_default().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
let _ = S.own_resize_default::<2>().s_assert_err(); // too small
Source

pub const fn own_resize_default_truncate<const NEW_CAP: usize>( self, ) -> Own<Stack<T, NEW_CAP, u16, Bare>, ()>

Available on crate feature _stack_u16 only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
const S: StackU16<i32, 8> = StackU16::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU16<i32, 4> = S.own_resize_default_truncate().s;
assert_eq![S.as_slice(), T.as_slice()];
const U: StackU16<i32, 2> = S.own_resize_default_truncate().s;
assert_eq![U.as_slice(), &[2, 3]];
Source§

impl<T, const CAP: usize> Stack<T, CAP, u16, Bare>

§Stack index-size conversion.

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>

Available on crate features _stack_u16 and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackU16::<_, 6>::from([1, 2, 3, 4]);
let t: StackU8::<_, 6> = s.to_idx_u8().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>

Available on crate feature _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackU16::<_, 6>::from([1, 2, 3, 4]);
let t: StackU16::<_, 6> = s.to_idx_u16().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>

Available on crate features _stack_u16 and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackU16::<_, 6>::from([1, 2, 3, 4]);
let t: StackU32::<_, 6> = s.to_idx_u32().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>

Available on crate features _stack_u16 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackU16::<_, 6>::from([1, 2, 3, 4]);
let t: StackUsize::<_, 6> = s.to_idx_usize().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source§

impl<T, const CAP: usize> Stack<T, CAP, u16, Boxed>

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u16 and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackU16::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU8::<_, 6, Boxed> = s.to_idx_u8().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackU16::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU16::<_, 6, Boxed> = s.to_idx_u16().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u16 and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackU16::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU32::<_, 6, Boxed> = s.to_idx_u32().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u16 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackU16::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackUsize::<_, 6, Boxed> = s.to_idx_usize().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u16, Bare>

Source

pub const fn own_to_idx_u8( self, ) -> Own<Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u16 and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
const S: StackU16<i32, 6> = StackU16::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU8<i32, 6> = S.own_to_idx_u8().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u16( self, ) -> Own<Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>, ()>

Available on crate feature _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
const S: StackU16<i32, 6> = StackU16::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU16<i32, 6> = S.own_to_idx_u16().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u32( self, ) -> Own<Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u16 and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
const S: StackU16<i32, 6> = StackU16::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU32<i32, 6> = S.own_to_idx_u32().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_usize( self, ) -> Own<Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u16 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
const S: StackU16<i32, 6> = StackU16::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackUsize<i32, 6> = S.own_to_idx_usize().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, u32, Bare>

§Stack resize.

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, u32, Bare>, IndexOutOfBounds>

Available on crate feature _stack_u32 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u32::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU32::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackU32::<_, 4> = s.resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackU32::<_, 12> = s.resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, u32, Bare>

Available on crate feature _stack_u32 only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackU32::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackU32::<_, 4> = s.resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackU32::<_, 12> = s.resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackU32::<_, 2> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, u32, Boxed>

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, u32, Boxed>, IndexOutOfBounds>

Available on crate features alloc and _stack_u32 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u32::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU32::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackU32::<_, 4, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackU32::<_, 12, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, u32, Boxed>

Available on crate features alloc and _stack_u32 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackU32::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackU32::<_, 4, Boxed> = s.clone().resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackU32::<_, 12, Boxed> = s.clone().resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackU32::<_, 2, Boxed> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: ConstDefault + Copy, const CAP: usize> Stack<T, CAP, u32, Bare>

Source

pub const fn own_resize_default<const NEW_CAP: usize>( self, ) -> Own<Result<Stack<T, NEW_CAP, u32, Bare>, IndexOutOfBounds>, ()>

Available on crate feature _stack_u32 only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > u32::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU32<i32, 8> = StackU32::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU32<i32, 4> = S.own_resize_default().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
let _ = S.own_resize_default::<2>().s_assert_err(); // too small
Source

pub const fn own_resize_default_truncate<const NEW_CAP: usize>( self, ) -> Own<Stack<T, NEW_CAP, u32, Bare>, ()>

Available on crate feature _stack_u32 only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
const S: StackU32<i32, 8> = StackU32::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU32<i32, 4> = S.own_resize_default_truncate().s;
assert_eq![S.as_slice(), T.as_slice()];
const U: StackU32<i32, 2> = S.own_resize_default_truncate().s;
assert_eq![U.as_slice(), &[2, 3]];
Source§

impl<T, const CAP: usize> Stack<T, CAP, u32, Bare>

§Stack index-size conversion.

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>

Available on crate features _stack_u32 and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackU32::<_, 6>::from([1, 2, 3, 4]);
let t: StackU8::<_, 6> = s.to_idx_u8().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>

Available on crate features _stack_u32 and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackU32::<_, 6>::from([1, 2, 3, 4]);
let t: StackU16::<_, 6> = s.to_idx_u16().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>

Available on crate feature _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackU32::<_, 6>::from([1, 2, 3, 4]);
let t: StackU32::<_, 6> = s.to_idx_u32().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>

Available on crate features _stack_u32 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackU32::<_, 6>::from([1, 2, 3, 4]);
let t: StackUsize::<_, 6> = s.to_idx_usize().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source§

impl<T, const CAP: usize> Stack<T, CAP, u32, Boxed>

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u32 and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackU32::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU8::<_, 6, Boxed> = s.to_idx_u8().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u32 and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackU32::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU16::<_, 6, Boxed> = s.to_idx_u16().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackU32::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU32::<_, 6, Boxed> = s.to_idx_u32().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_u32 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackU32::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackUsize::<_, 6, Boxed> = s.to_idx_usize().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u32, Bare>

Source

pub const fn own_to_idx_u8( self, ) -> Own<Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u32 and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
const S: StackU32<i32, 6> = StackU32::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU8<i32, 6> = S.own_to_idx_u8().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u16( self, ) -> Own<Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u32 and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
const S: StackU32<i32, 6> = StackU32::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU16<i32, 6> = S.own_to_idx_u16().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u32( self, ) -> Own<Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>, ()>

Available on crate feature _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
const S: StackU32<i32, 6> = StackU32::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU32<i32, 6> = S.own_to_idx_u32().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_usize( self, ) -> Own<Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_u32 and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
const S: StackU32<i32, 6> = StackU32::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackUsize<i32, 6> = S.own_to_idx_usize().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, usize, Bare>

§Stack resize.

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, usize, Bare>, IndexOutOfBounds>

Available on crate feature _stack_usize only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > usize::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackUsize::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackUsize::<_, 4> = s.resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackUsize::<_, 12> = s.resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, usize, Bare>

Available on crate feature _stack_usize only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackUsize::<_, 8>::from([1, 2, 3, 4]);
let less_cap: StackUsize::<_, 4> = s.resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackUsize::<_, 12> = s.resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackUsize::<_, 2> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: Default, const CAP: usize> Stack<T, CAP, usize, Boxed>

Source

pub fn resize_default<const NEW_CAP: usize>( self, ) -> Result<Stack<T, NEW_CAP, usize, Boxed>, IndexOutOfBounds>

Available on crate features alloc and _stack_usize only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > usize::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackUsize::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackUsize::<_, 4, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), less_cap.as_slice()];
let more_cap: StackUsize::<_, 12, Boxed> = s.clone().resize_default().unwrap();
assert_eq![s.as_slice(), more_cap.as_slice()];
assert![s.resize_default::<2>().is_err()]; // too small
Source

pub fn resize_default_truncate<const NEW_CAP: usize>( self, ) -> Stack<T, NEW_CAP, usize, Boxed>

Available on crate features alloc and _stack_usize only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
let s = StackUsize::<_, 8, Boxed>::from([1, 2, 3, 4]);
let less_cap: StackUsize::<_, 4, Boxed> = s.clone().resize_default_truncate();
assert_eq![less_cap.as_slice(), s.as_slice()];
let more_cap: StackUsize::<_, 12, Boxed> = s.clone().resize_default_truncate();
assert_eq![more_cap.as_slice(), s.as_slice()];
let drop_cap: StackUsize::<_, 2, Boxed> = s.resize_default_truncate();
assert_eq![drop_cap.as_slice(), &[3, 4]];
Source§

impl<T: ConstDefault + Copy, const CAP: usize> Stack<T, CAP, usize, Bare>

Source

pub const fn own_resize_default<const NEW_CAP: usize>( self, ) -> Own<Result<Stack<T, NEW_CAP, usize, Bare>, IndexOutOfBounds>, ()>

Available on crate feature _stack_usize only.

Converts the current stack to a different capacity while preserving all existing elements.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation ensures that the new stack can accommodate the number of elements currently held in the stack. It is designed to work with both increases and decreases in capacity, as long as the new capacity can fit the current number of elements.

§Errors

Returns [IndexOutOfBounds(Some(NEW_CAP))] if NEW_CAP < self.len(), if CAP > usize::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackUsize<i32, 8> = StackUsize::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackUsize<i32, 4> = S.own_resize_default().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
let _ = S.own_resize_default::<2>().s_assert_err(); // too small
Source

pub const fn own_resize_default_truncate<const NEW_CAP: usize>( self, ) -> Own<Stack<T, NEW_CAP, usize, Bare>, ()>

Available on crate feature _stack_usize only.

Converts the current stack to a different capacity, dropping elements if needed.

This method creates a new stack with the specified new capacity and moves the current elements into it. The operation will drop any elements that can’t fit in the new capacity, starting with the first ones (from the front of the stack).

§Examples
const S: StackUsize<i32, 8> = StackUsize::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackUsize<i32, 4> = S.own_resize_default_truncate().s;
assert_eq![S.as_slice(), T.as_slice()];
const U: StackUsize<i32, 2> = S.own_resize_default_truncate().s;
assert_eq![U.as_slice(), &[2, 3]];
Source§

impl<T, const CAP: usize> Stack<T, CAP, usize, Bare>

§Stack index-size conversion.

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>

Available on crate features _stack_usize and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackUsize::<_, 6>::from([1, 2, 3, 4]);
let t: StackU8::<_, 6> = s.to_idx_u8().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>

Available on crate features _stack_usize and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackUsize::<_, 6>::from([1, 2, 3, 4]);
let t: StackU16::<_, 6> = s.to_idx_u16().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>

Available on crate features _stack_usize and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackUsize::<_, 6>::from([1, 2, 3, 4]);
let t: StackU32::<_, 6> = s.to_idx_u32().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>

Available on crate feature _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackUsize::<_, 6>::from([1, 2, 3, 4]);
let t: StackUsize::<_, 6> = s.to_idx_usize().unwrap();
assert_eq![s.as_slice(), t.as_slice()];
Source§

impl<T, const CAP: usize> Stack<T, CAP, usize, Boxed>

Source

pub fn to_idx_u8(self) -> Result<Stack<T, CAP, u8, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_usize and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
let s = StackUsize::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU8::<_, 6, Boxed> = s.to_idx_u8().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u16(self) -> Result<Stack<T, CAP, u16, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_usize and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
let s = StackUsize::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU16::<_, 6, Boxed> = s.to_idx_u16().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_u32(self) -> Result<Stack<T, CAP, u32, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_usize and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
let s = StackUsize::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackU32::<_, 6, Boxed> = s.to_idx_u32().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source

pub fn to_idx_usize(self) -> Result<Stack<T, CAP, usize, Boxed>, NotEnoughSpace>

Available on crate features alloc and _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
let s = StackUsize::<_, 6, Boxed>::from([1, 2, 3]);
let t: StackUsize::<_, 6, Boxed> = s.to_idx_usize().unwrap();
assert_eq![t.as_slice(), &[1, 2, 3]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, usize, Bare>

Source

pub const fn own_to_idx_u8( self, ) -> Own<Result<Stack<T, CAP, u8, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_usize and _stack_u8 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u8::MAX.

§Examples
const S: StackUsize<i32, 6> = StackUsize::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU8<i32, 6> = S.own_to_idx_u8().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u16( self, ) -> Own<Result<Stack<T, CAP, u16, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_usize and _stack_u16 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u16::MAX.

§Examples
const S: StackUsize<i32, 6> = StackUsize::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU16<i32, 6> = S.own_to_idx_u16().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_u32( self, ) -> Own<Result<Stack<T, CAP, u32, Bare>, NotEnoughSpace>, ()>

Available on crate features _stack_usize and _stack_u32 only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > u32::MAX.

§Examples
const S: StackUsize<i32, 6> = StackUsize::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackU32<i32, 6> = S.own_to_idx_u32().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source

pub const fn own_to_idx_usize( self, ) -> Own<Result<Stack<T, CAP, usize, Bare>, NotEnoughSpace>, ()>

Available on crate feature _stack_usize only.

Converts the current stack index size IDX to a NEW_IDX.

§Errors

Returns NotEnoughSpace if CAP > usize::MAX.

§Examples
const S: StackUsize<i32, 6> = StackUsize::own_new(0)
    .s_const_unwrap().s.own_push(1).s.own_push(2).s.own_push(3).s;
const T: StackUsize<i32, 6> = S.own_to_idx_usize().s_const_unwrap().s;
assert_eq![S.as_slice(), T.as_slice()];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u8, Bare>

§Methods for StackU8



This impl block contains no items.
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u8, Bare>

Source

pub fn new(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, cloning element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > u8::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU8::<_, 16>::new(0).unwrap();
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u8, Bare>

Source

pub const fn new_copied(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data, in compile-time.

§Errors

Returns MismatchedCapacity if CAP > u8::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU8<i32, 16> = unwrap![ok StackU8::new_copied(0)];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u8, Boxed>

Source

pub fn new(element: T) -> Self

Available on crate feature alloc only.

Returns an empty stack, allocated in the heap, cloning element to fill the remaining free data.

§Examples
let s = StackU8::<_, 100, Boxed>::new(0);
Source§

impl<T, const CAP: usize> Stack<T, CAP, u8, Bare>

Source

pub const fn from_array_copy(arr: [T; CAP]) -> Stack<T, CAP, u8, Bare>

Converts an array into a full stack.

§Examples
const S: StackU8<i32, 3> = StackU8::from_array_copy([1, 2, 3]);
Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, u8, S>

Source

pub fn from_array(arr: [T; CAP]) -> Stack<T, CAP, u8, S>

Converts an array into a full stack.

§Examples
let s = StackU8::<_, 3>::from_array([1, 2, 3]);
Source

pub const fn len(&self) -> u8

Returns the number of stacked elements.

Source

pub const fn is_empty(&self) -> bool

Returns true if the stack is empty.

§Examples
let s = StackU8::<i32, 8>::default();
assert![s.is_empty()];
Source

pub const fn is_full(&self) -> bool

Returns true if the stack is full.

§Examples
let s = StackU8::<_, 3>::from([1, 2, 3]);
assert![s.is_full()];
Source

pub const fn capacity(&self) -> u8

Returns the stack’s total capacity.

§Examples
let s = StackU8::<i32, 3>::default();
assert_eq![3, s.capacity()];
Source

pub const fn remaining_capacity(&self) -> u8

Returns the stack’s remaining capacity.

§Examples
let mut s = StackU8::<_, 3>::default();
assert_eq![3, s.remaining_capacity()];
s.push(1)?;
assert_eq![2, s.remaining_capacity()];
Source

pub fn as_slice(&self) -> &[T]

Returns the stack as a shared slice.

§Examples
let s = StackU8::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];
Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the stack as an exclusive slice.

§Examples
let mut s = StackU8::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_mut_slice(), &mut [1, 2, 3]];
Source

pub const fn clear(&mut self)

Clears the stack.

( 1 2 3 -- )

§Examples
let mut s = StackU8::<_, 8>::from([1, 2, 3, 4]);
s.clear();
assert![s.is_empty()];
Source

pub fn push(&mut self, element: T) -> Result<(), NotEnoughSpace>

Pushes a new element to the top of the stack.

( 1 -- 1 2 )

§Errors

Returns NotEnoughSpace if the stack is full.

§Examples
let mut s = StackU8::<_, 2>::default();
s.push(1)?;
s.push(2)?;
assert![s.push(3).is_err()];
assert_eq![s.as_slice(), &[1, 2]];
Source

pub fn pop(&mut self) -> Result<T, NotEnoughElements>

Available on crate feature unsafe_ptr or Clone only.

Pops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU8::<_, 2>::from([1, 2]);
assert_eq![2, s.pop()?];
assert_eq![1, s.pop()?];
assert![s.is_empty()];
§Features

It’s depends on T: Clone, unless the unsafe_ptr feature is enabled.

Source

pub fn peek(&self) -> Result<&T, NotEnoughElements>

Peeks the top stack element.

( 1 -- 1 )

Returns a shared reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let s = StackU8::<_, 2>::from([1, 2]);
assert_eq![s.peek(), Ok(&2)];
Source

pub fn peek_mut(&mut self) -> Result<&mut T, NotEnoughElements>

Mutably peeks the top stack element.

( 1 -- 1 )

Returns an exclusive reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU8::<_, 2>::from([1, 2]);
assert_eq![s.peek_mut(), Ok(&mut 2)];
Source

pub fn peek_nth(&self, nth: u8) -> Result<&T, NotEnoughElements>

Peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns a shared reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let s = StackU8::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth(0), Ok(&5)];
assert_eq![s.peek_nth(4), Ok(&1)];
Source

pub fn peek_nth_mut(&mut self, nth: u8) -> Result<&mut T, NotEnoughElements>

Mutably peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns an exclusive reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let mut s = StackU8::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth_mut(0), Ok(&mut 5)];
assert_eq![s.peek_nth_mut(4), Ok(&mut 1)];
Source

pub fn drop(&mut self) -> Result<(), NotEnoughElements>

Drops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU8::<_, 2>::from([1, 2]);
s.drop();
assert_eq![s.as_slice(), &[1]];
Source

pub fn drop_n(&mut self, n: u8) -> Result<(), NotEnoughElements>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least n elements.

§Examples
let mut s = StackU8::<_, 4>::from([1, 2, 3, 4]);
s.drop_n(3);
assert_eq![s.as_slice(), &[1]];
Source

pub fn nip(&mut self) -> Result<(), NotEnoughElements>

Drops the next of stack element.

( 1 2 -- 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackU8::<_, 2>::from([1, 2]);
s.nip();
assert_eq![s.as_slice(), &[2]];
Source

pub fn nip2(&mut self) -> Result<(), NotEnoughElements>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackU8::<_, 8>::from([1, 2, 3, 4]);
s.nip2();
assert_eq![s.as_slice(), &[3, 4]];
Source

pub fn swap(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two stack elements.

( 1 2 -- 2 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackU8::<_, 2>::from([1, 2]);
s.swap();
assert_eq![s.as_slice(), &[2, 1]];
Source

pub fn swap2(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two pair stack elements.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackU8::<_, 4>::from([1, 2, 3, 4]);
s.swap2();
assert_eq![s.as_slice(), &[3, 4, 1, 2]];
Source

pub fn rot(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackU8::<_, 3>::from(['a', 'b', 'c']);
s.rot()?;
assert_eq![s.as_slice(), &['b', 'c', 'a']];
Source

pub fn rot_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackU8::<_, 3>::from(['a', 'b', 'c']);
s.rot_cc()?;
assert_eq![s.as_slice(), &['c', 'a', 'b']];
Source

pub fn rot2(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackU8::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source

pub fn rot2_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackU8::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source§

impl<T: Clone, const CAP: usize, S: Storage> Stack<T, CAP, u8, S>

§Operations depending on T: Clone

Every method is const and returns Own<Self, V>.

Source

pub fn dup(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns DataNotEnough::Elements if the stack is empty or DataNotEnough::Space if the stack is full.

§Examples
let mut s = StackU8::<_, 2>::from([1]);
s.dup()?;
assert_eq![&[1, 1], s.as_slice()];
Source

pub fn dup2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU8::<_, 5>::from([1, 2]);
s.dup2()?;
assert_eq![&[1, 2, 1, 2], s.as_slice()];
Source

pub fn over(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackU8::<_, 3>::from([1, 2]);
s.over()?;
assert_eq![&[1, 2, 1], s.as_slice()];
Source

pub fn over2(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU8::<_, 6>::from([1, 2, 3, 4]);
s.over2()?;
assert_eq![&[1, 2, 3, 4, 1, 2], s.as_slice()];
Source

pub fn tuck(&mut self) -> Result<(), DataNotEnough>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackU8::<_, 3>::from([1, 2]);
s.tuck()?;
assert_eq![&[2, 1, 2], s.as_slice()];
Source

pub fn tuck2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU8::<_, 6>::from([1, 2, 3, 4]);
s.tuck2()?;
assert_eq![&[3, 4, 1, 2, 3, 4], s.as_slice()];
Source

pub fn to_vec(&self) -> Vec<T>

Available on crate feature alloc only.

Returns the stacked elements as a vector.

§Examples
let mut s = StackU8::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_vec(), vec![1, 2, 3, 4, 5]];
Source

pub fn to_array<const LEN: usize>(&self) -> Option<[T; LEN]>

Returns some LEN stacked elements as an array, or None if the stack is empty, or there are not at least LEN elements.

This is a non alloc alternative method to to_vec.

§Panics

Panics if the new LEN sized array can’t be allocated.

§Examples
let mut s = StackU8::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_array::<5>(), Some([1, 2, 3, 4, 5])];
§Features

Makes use of the unsafe_array feature if enabled.

Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, u8, S>

Source

pub const fn iter(&self) -> StackIter<'_, T, CAP, u8, S>

Returns an iterator.

Source

pub fn extend<I>(&mut self, iterator: I) -> Result<(), NotEnoughSpace>
where I: IntoIterator<Item = T>,

Extends the stack from an iterator.

§Errors

Returns NotEnoughSpace if the stack becomes full before the iterator finishes.

§Examples
let mut s = StackU8::<_, 5>::default();
s.extend([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];

s.extend([4, 5, 6, 7, 8]);
assert_eq![s.as_slice(), &[1, 2, 3, 4, 5]];
Source§

impl<T: PartialEq, const CAP: usize, S: Storage> Stack<T, CAP, u8, S>

Source

pub fn contains(&self, element: &T) -> bool

Returns true if the stack contains element.

§Examples
let s = StackU8::<_, 6>::from([5, 78, 42, 33, 9]);

assert![s.contains(&9)];
assert![!s.contains(&8)];
Source§

impl<T: Default, const CAP: usize, S: Storage> Stack<T, CAP, u8, S>

Source

pub fn drop_replace_default(&mut self) -> Result<(), NotEnoughElements>

Drops the top of stack element, replacing the underlying data with the default value.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU8::<_, 2>::from([1, 2]);
s.drop_replace_default();
assert_eq![s.as_slice(), &[1]];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u16, Bare>

§Methods for StackU16



This impl block contains no items.
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u16, Bare>

Source

pub fn new(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, cloning element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > u16::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU16::<_, 16>::new(0).unwrap();
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u16, Bare>

Source

pub const fn new_copied(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data, in compile-time.

§Errors

Returns MismatchedCapacity if CAP > u16::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU16<i32, 16> = unwrap![ok StackU16::new_copied(0)];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u16, Boxed>

Source

pub fn new(element: T) -> Self

Available on crate feature alloc only.

Returns an empty stack, allocated in the heap, cloning element to fill the remaining free data.

§Examples
let s = StackU16::<_, 100, Boxed>::new(0);
Source§

impl<T, const CAP: usize> Stack<T, CAP, u16, Bare>

Source

pub const fn from_array_copy(arr: [T; CAP]) -> Stack<T, CAP, u16, Bare>

Converts an array into a full stack.

§Examples
const S: StackU16<i32, 3> = StackU16::from_array_copy([1, 2, 3]);
Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, u16, S>

Source

pub fn from_array(arr: [T; CAP]) -> Stack<T, CAP, u16, S>

Converts an array into a full stack.

§Examples
let s = StackU16::<_, 3>::from_array([1, 2, 3]);
Source

pub const fn len(&self) -> u16

Returns the number of stacked elements.

Source

pub const fn is_empty(&self) -> bool

Returns true if the stack is empty.

§Examples
let s = StackU16::<i32, 8>::default();
assert![s.is_empty()];
Source

pub const fn is_full(&self) -> bool

Returns true if the stack is full.

§Examples
let s = StackU16::<_, 3>::from([1, 2, 3]);
assert![s.is_full()];
Source

pub const fn capacity(&self) -> u16

Returns the stack’s total capacity.

§Examples
let s = StackU16::<i32, 3>::default();
assert_eq![3, s.capacity()];
Source

pub const fn remaining_capacity(&self) -> u16

Returns the stack’s remaining capacity.

§Examples
let mut s = StackU16::<_, 3>::default();
assert_eq![3, s.remaining_capacity()];
s.push(1)?;
assert_eq![2, s.remaining_capacity()];
Source

pub fn as_slice(&self) -> &[T]

Returns the stack as a shared slice.

§Examples
let s = StackU16::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];
Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the stack as an exclusive slice.

§Examples
let mut s = StackU16::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_mut_slice(), &mut [1, 2, 3]];
Source

pub const fn clear(&mut self)

Clears the stack.

( 1 2 3 -- )

§Examples
let mut s = StackU16::<_, 8>::from([1, 2, 3, 4]);
s.clear();
assert![s.is_empty()];
Source

pub fn push(&mut self, element: T) -> Result<(), NotEnoughSpace>

Pushes a new element to the top of the stack.

( 1 -- 1 2 )

§Errors

Returns NotEnoughSpace if the stack is full.

§Examples
let mut s = StackU16::<_, 2>::default();
s.push(1)?;
s.push(2)?;
assert![s.push(3).is_err()];
assert_eq![s.as_slice(), &[1, 2]];
Source

pub fn pop(&mut self) -> Result<T, NotEnoughElements>

Available on crate feature unsafe_ptr or Clone only.

Pops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU16::<_, 2>::from([1, 2]);
assert_eq![2, s.pop()?];
assert_eq![1, s.pop()?];
assert![s.is_empty()];
§Features

It’s depends on T: Clone, unless the unsafe_ptr feature is enabled.

Source

pub fn peek(&self) -> Result<&T, NotEnoughElements>

Peeks the top stack element.

( 1 -- 1 )

Returns a shared reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let s = StackU16::<_, 2>::from([1, 2]);
assert_eq![s.peek(), Ok(&2)];
Source

pub fn peek_mut(&mut self) -> Result<&mut T, NotEnoughElements>

Mutably peeks the top stack element.

( 1 -- 1 )

Returns an exclusive reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU16::<_, 2>::from([1, 2]);
assert_eq![s.peek_mut(), Ok(&mut 2)];
Source

pub fn peek_nth(&self, nth: u16) -> Result<&T, NotEnoughElements>

Peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns a shared reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let s = StackU16::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth(0), Ok(&5)];
assert_eq![s.peek_nth(4), Ok(&1)];
Source

pub fn peek_nth_mut(&mut self, nth: u16) -> Result<&mut T, NotEnoughElements>

Mutably peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns an exclusive reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let mut s = StackU16::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth_mut(0), Ok(&mut 5)];
assert_eq![s.peek_nth_mut(4), Ok(&mut 1)];
Source

pub fn drop(&mut self) -> Result<(), NotEnoughElements>

Drops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU16::<_, 2>::from([1, 2]);
s.drop();
assert_eq![s.as_slice(), &[1]];
Source

pub fn drop_n(&mut self, n: u16) -> Result<(), NotEnoughElements>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least n elements.

§Examples
let mut s = StackU16::<_, 4>::from([1, 2, 3, 4]);
s.drop_n(3);
assert_eq![s.as_slice(), &[1]];
Source

pub fn nip(&mut self) -> Result<(), NotEnoughElements>

Drops the next of stack element.

( 1 2 -- 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackU16::<_, 2>::from([1, 2]);
s.nip();
assert_eq![s.as_slice(), &[2]];
Source

pub fn nip2(&mut self) -> Result<(), NotEnoughElements>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackU16::<_, 8>::from([1, 2, 3, 4]);
s.nip2();
assert_eq![s.as_slice(), &[3, 4]];
Source

pub fn swap(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two stack elements.

( 1 2 -- 2 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackU16::<_, 2>::from([1, 2]);
s.swap();
assert_eq![s.as_slice(), &[2, 1]];
Source

pub fn swap2(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two pair stack elements.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackU16::<_, 4>::from([1, 2, 3, 4]);
s.swap2();
assert_eq![s.as_slice(), &[3, 4, 1, 2]];
Source

pub fn rot(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackU16::<_, 3>::from(['a', 'b', 'c']);
s.rot()?;
assert_eq![s.as_slice(), &['b', 'c', 'a']];
Source

pub fn rot_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackU16::<_, 3>::from(['a', 'b', 'c']);
s.rot_cc()?;
assert_eq![s.as_slice(), &['c', 'a', 'b']];
Source

pub fn rot2(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackU16::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source

pub fn rot2_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackU16::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source§

impl<T: Clone, const CAP: usize, S: Storage> Stack<T, CAP, u16, S>

§Operations depending on T: Clone

Every method is const and returns Own<Self, V>.

Source

pub fn dup(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns DataNotEnough::Elements if the stack is empty or DataNotEnough::Space if the stack is full.

§Examples
let mut s = StackU16::<_, 2>::from([1]);
s.dup()?;
assert_eq![&[1, 1], s.as_slice()];
Source

pub fn dup2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU16::<_, 5>::from([1, 2]);
s.dup2()?;
assert_eq![&[1, 2, 1, 2], s.as_slice()];
Source

pub fn over(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackU16::<_, 3>::from([1, 2]);
s.over()?;
assert_eq![&[1, 2, 1], s.as_slice()];
Source

pub fn over2(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU16::<_, 6>::from([1, 2, 3, 4]);
s.over2()?;
assert_eq![&[1, 2, 3, 4, 1, 2], s.as_slice()];
Source

pub fn tuck(&mut self) -> Result<(), DataNotEnough>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackU16::<_, 3>::from([1, 2]);
s.tuck()?;
assert_eq![&[2, 1, 2], s.as_slice()];
Source

pub fn tuck2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU16::<_, 6>::from([1, 2, 3, 4]);
s.tuck2()?;
assert_eq![&[3, 4, 1, 2, 3, 4], s.as_slice()];
Source

pub fn to_vec(&self) -> Vec<T>

Available on crate feature alloc only.

Returns the stacked elements as a vector.

§Examples
let mut s = StackU16::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_vec(), vec![1, 2, 3, 4, 5]];
Source

pub fn to_array<const LEN: usize>(&self) -> Option<[T; LEN]>

Returns some LEN stacked elements as an array, or None if the stack is empty, or there are not at least LEN elements.

This is a non alloc alternative method to to_vec.

§Panics

Panics if the new LEN sized array can’t be allocated.

§Examples
let mut s = StackU16::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_array::<5>(), Some([1, 2, 3, 4, 5])];
§Features

Makes use of the unsafe_array feature if enabled.

Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, u16, S>

Source

pub const fn iter(&self) -> StackIter<'_, T, CAP, u16, S>

Returns an iterator.

Source

pub fn extend<I>(&mut self, iterator: I) -> Result<(), NotEnoughSpace>
where I: IntoIterator<Item = T>,

Extends the stack from an iterator.

§Errors

Returns NotEnoughSpace if the stack becomes full before the iterator finishes.

§Examples
let mut s = StackU16::<_, 5>::default();
s.extend([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];

s.extend([4, 5, 6, 7, 8]);
assert_eq![s.as_slice(), &[1, 2, 3, 4, 5]];
Source§

impl<T: PartialEq, const CAP: usize, S: Storage> Stack<T, CAP, u16, S>

Source

pub fn contains(&self, element: &T) -> bool

Returns true if the stack contains element.

§Examples
let s = StackU16::<_, 6>::from([5, 78, 42, 33, 9]);

assert![s.contains(&9)];
assert![!s.contains(&8)];
Source§

impl<T: Default, const CAP: usize, S: Storage> Stack<T, CAP, u16, S>

Source

pub fn drop_replace_default(&mut self) -> Result<(), NotEnoughElements>

Drops the top of stack element, replacing the underlying data with the default value.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU16::<_, 2>::from([1, 2]);
s.drop_replace_default();
assert_eq![s.as_slice(), &[1]];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u32, Bare>

§Methods for StackU32



This impl block contains no items.
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u32, Bare>

Source

pub fn new(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, cloning element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > u32::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackU32::<_, 16>::new(0).unwrap();
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u32, Bare>

Source

pub const fn new_copied(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data, in compile-time.

§Errors

Returns MismatchedCapacity if CAP > u32::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU32<i32, 16> = unwrap![ok StackU32::new_copied(0)];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, u32, Boxed>

Source

pub fn new(element: T) -> Self

Available on crate feature alloc only.

Returns an empty stack, allocated in the heap, cloning element to fill the remaining free data.

§Examples
let s = StackU32::<_, 100, Boxed>::new(0);
Source§

impl<T, const CAP: usize> Stack<T, CAP, u32, Bare>

Source

pub const fn from_array_copy(arr: [T; CAP]) -> Stack<T, CAP, u32, Bare>

Converts an array into a full stack.

§Examples
const S: StackU32<i32, 3> = StackU32::from_array_copy([1, 2, 3]);
Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, u32, S>

Source

pub fn from_array(arr: [T; CAP]) -> Stack<T, CAP, u32, S>

Converts an array into a full stack.

§Examples
let s = StackU32::<_, 3>::from_array([1, 2, 3]);
Source

pub const fn len(&self) -> u32

Returns the number of stacked elements.

Source

pub const fn is_empty(&self) -> bool

Returns true if the stack is empty.

§Examples
let s = StackU32::<i32, 8>::default();
assert![s.is_empty()];
Source

pub const fn is_full(&self) -> bool

Returns true if the stack is full.

§Examples
let s = StackU32::<_, 3>::from([1, 2, 3]);
assert![s.is_full()];
Source

pub const fn capacity(&self) -> u32

Returns the stack’s total capacity.

§Examples
let s = StackU32::<i32, 3>::default();
assert_eq![3, s.capacity()];
Source

pub const fn remaining_capacity(&self) -> u32

Returns the stack’s remaining capacity.

§Examples
let mut s = StackU32::<_, 3>::default();
assert_eq![3, s.remaining_capacity()];
s.push(1)?;
assert_eq![2, s.remaining_capacity()];
Source

pub fn as_slice(&self) -> &[T]

Returns the stack as a shared slice.

§Examples
let s = StackU32::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];
Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the stack as an exclusive slice.

§Examples
let mut s = StackU32::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_mut_slice(), &mut [1, 2, 3]];
Source

pub const fn clear(&mut self)

Clears the stack.

( 1 2 3 -- )

§Examples
let mut s = StackU32::<_, 8>::from([1, 2, 3, 4]);
s.clear();
assert![s.is_empty()];
Source

pub fn push(&mut self, element: T) -> Result<(), NotEnoughSpace>

Pushes a new element to the top of the stack.

( 1 -- 1 2 )

§Errors

Returns NotEnoughSpace if the stack is full.

§Examples
let mut s = StackU32::<_, 2>::default();
s.push(1)?;
s.push(2)?;
assert![s.push(3).is_err()];
assert_eq![s.as_slice(), &[1, 2]];
Source

pub fn pop(&mut self) -> Result<T, NotEnoughElements>

Available on crate feature unsafe_ptr or Clone only.

Pops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU32::<_, 2>::from([1, 2]);
assert_eq![2, s.pop()?];
assert_eq![1, s.pop()?];
assert![s.is_empty()];
§Features

It’s depends on T: Clone, unless the unsafe_ptr feature is enabled.

Source

pub fn peek(&self) -> Result<&T, NotEnoughElements>

Peeks the top stack element.

( 1 -- 1 )

Returns a shared reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let s = StackU32::<_, 2>::from([1, 2]);
assert_eq![s.peek(), Ok(&2)];
Source

pub fn peek_mut(&mut self) -> Result<&mut T, NotEnoughElements>

Mutably peeks the top stack element.

( 1 -- 1 )

Returns an exclusive reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU32::<_, 2>::from([1, 2]);
assert_eq![s.peek_mut(), Ok(&mut 2)];
Source

pub fn peek_nth(&self, nth: u32) -> Result<&T, NotEnoughElements>

Peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns a shared reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let s = StackU32::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth(0), Ok(&5)];
assert_eq![s.peek_nth(4), Ok(&1)];
Source

pub fn peek_nth_mut(&mut self, nth: u32) -> Result<&mut T, NotEnoughElements>

Mutably peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns an exclusive reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let mut s = StackU32::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth_mut(0), Ok(&mut 5)];
assert_eq![s.peek_nth_mut(4), Ok(&mut 1)];
Source

pub fn drop(&mut self) -> Result<(), NotEnoughElements>

Drops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU32::<_, 2>::from([1, 2]);
s.drop();
assert_eq![s.as_slice(), &[1]];
Source

pub fn drop_n(&mut self, n: u32) -> Result<(), NotEnoughElements>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least n elements.

§Examples
let mut s = StackU32::<_, 4>::from([1, 2, 3, 4]);
s.drop_n(3);
assert_eq![s.as_slice(), &[1]];
Source

pub fn nip(&mut self) -> Result<(), NotEnoughElements>

Drops the next of stack element.

( 1 2 -- 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackU32::<_, 2>::from([1, 2]);
s.nip();
assert_eq![s.as_slice(), &[2]];
Source

pub fn nip2(&mut self) -> Result<(), NotEnoughElements>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackU32::<_, 8>::from([1, 2, 3, 4]);
s.nip2();
assert_eq![s.as_slice(), &[3, 4]];
Source

pub fn swap(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two stack elements.

( 1 2 -- 2 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackU32::<_, 2>::from([1, 2]);
s.swap();
assert_eq![s.as_slice(), &[2, 1]];
Source

pub fn swap2(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two pair stack elements.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackU32::<_, 4>::from([1, 2, 3, 4]);
s.swap2();
assert_eq![s.as_slice(), &[3, 4, 1, 2]];
Source

pub fn rot(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackU32::<_, 3>::from(['a', 'b', 'c']);
s.rot()?;
assert_eq![s.as_slice(), &['b', 'c', 'a']];
Source

pub fn rot_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackU32::<_, 3>::from(['a', 'b', 'c']);
s.rot_cc()?;
assert_eq![s.as_slice(), &['c', 'a', 'b']];
Source

pub fn rot2(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackU32::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source

pub fn rot2_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackU32::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source§

impl<T: Clone, const CAP: usize, S: Storage> Stack<T, CAP, u32, S>

§Operations depending on T: Clone

Every method is const and returns Own<Self, V>.

Source

pub fn dup(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns DataNotEnough::Elements if the stack is empty or DataNotEnough::Space if the stack is full.

§Examples
let mut s = StackU32::<_, 2>::from([1]);
s.dup()?;
assert_eq![&[1, 1], s.as_slice()];
Source

pub fn dup2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU32::<_, 5>::from([1, 2]);
s.dup2()?;
assert_eq![&[1, 2, 1, 2], s.as_slice()];
Source

pub fn over(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackU32::<_, 3>::from([1, 2]);
s.over()?;
assert_eq![&[1, 2, 1], s.as_slice()];
Source

pub fn over2(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU32::<_, 6>::from([1, 2, 3, 4]);
s.over2()?;
assert_eq![&[1, 2, 3, 4, 1, 2], s.as_slice()];
Source

pub fn tuck(&mut self) -> Result<(), DataNotEnough>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackU32::<_, 3>::from([1, 2]);
s.tuck()?;
assert_eq![&[2, 1, 2], s.as_slice()];
Source

pub fn tuck2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackU32::<_, 6>::from([1, 2, 3, 4]);
s.tuck2()?;
assert_eq![&[3, 4, 1, 2, 3, 4], s.as_slice()];
Source

pub fn to_vec(&self) -> Vec<T>

Available on crate feature alloc only.

Returns the stacked elements as a vector.

§Examples
let mut s = StackU32::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_vec(), vec![1, 2, 3, 4, 5]];
Source

pub fn to_array<const LEN: usize>(&self) -> Option<[T; LEN]>

Returns some LEN stacked elements as an array, or None if the stack is empty, or there are not at least LEN elements.

This is a non alloc alternative method to to_vec.

§Panics

Panics if the new LEN sized array can’t be allocated.

§Examples
let mut s = StackU32::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_array::<5>(), Some([1, 2, 3, 4, 5])];
§Features

Makes use of the unsafe_array feature if enabled.

Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, u32, S>

Source

pub const fn iter(&self) -> StackIter<'_, T, CAP, u32, S>

Returns an iterator.

Source

pub fn extend<I>(&mut self, iterator: I) -> Result<(), NotEnoughSpace>
where I: IntoIterator<Item = T>,

Extends the stack from an iterator.

§Errors

Returns NotEnoughSpace if the stack becomes full before the iterator finishes.

§Examples
let mut s = StackU32::<_, 5>::default();
s.extend([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];

s.extend([4, 5, 6, 7, 8]);
assert_eq![s.as_slice(), &[1, 2, 3, 4, 5]];
Source§

impl<T: PartialEq, const CAP: usize, S: Storage> Stack<T, CAP, u32, S>

Source

pub fn contains(&self, element: &T) -> bool

Returns true if the stack contains element.

§Examples
let s = StackU32::<_, 6>::from([5, 78, 42, 33, 9]);

assert![s.contains(&9)];
assert![!s.contains(&8)];
Source§

impl<T: Default, const CAP: usize, S: Storage> Stack<T, CAP, u32, S>

Source

pub fn drop_replace_default(&mut self) -> Result<(), NotEnoughElements>

Drops the top of stack element, replacing the underlying data with the default value.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackU32::<_, 2>::from([1, 2]);
s.drop_replace_default();
assert_eq![s.as_slice(), &[1]];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, usize, Bare>

§Methods for StackUsize



This impl block contains no items.
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, usize, Bare>

Source

pub fn new(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, cloning element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > usize::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
let s = StackUsize::<_, 16>::new(0).unwrap();
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, usize, Bare>

Source

pub const fn new_copied(element: T) -> Result<Self, MismatchedCapacity>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data, in compile-time.

§Errors

Returns MismatchedCapacity if CAP > usize::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackUsize<i32, 16> = unwrap![ok StackUsize::new_copied(0)];
Source§

impl<T: Clone, const CAP: usize> Stack<T, CAP, usize, Boxed>

Source

pub fn new(element: T) -> Self

Available on crate feature alloc only.

Returns an empty stack, allocated in the heap, cloning element to fill the remaining free data.

§Examples
let s = StackUsize::<_, 100, Boxed>::new(0);
Source§

impl<T, const CAP: usize> Stack<T, CAP, usize, Bare>

Source

pub const fn from_array_copy(arr: [T; CAP]) -> Stack<T, CAP, usize, Bare>

Converts an array into a full stack.

§Examples
const S: StackUsize<i32, 3> = StackUsize::from_array_copy([1, 2, 3]);
Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, usize, S>

Source

pub fn from_array(arr: [T; CAP]) -> Stack<T, CAP, usize, S>

Converts an array into a full stack.

§Examples
let s = StackUsize::<_, 3>::from_array([1, 2, 3]);
Source

pub const fn len(&self) -> usize

Returns the number of stacked elements.

Source

pub const fn is_empty(&self) -> bool

Returns true if the stack is empty.

§Examples
let s = StackUsize::<i32, 8>::default();
assert![s.is_empty()];
Source

pub const fn is_full(&self) -> bool

Returns true if the stack is full.

§Examples
let s = StackUsize::<_, 3>::from([1, 2, 3]);
assert![s.is_full()];
Source

pub const fn capacity(&self) -> usize

Returns the stack’s total capacity.

§Examples
let s = StackUsize::<i32, 3>::default();
assert_eq![3, s.capacity()];
Source

pub const fn remaining_capacity(&self) -> usize

Returns the stack’s remaining capacity.

§Examples
let mut s = StackUsize::<_, 3>::default();
assert_eq![3, s.remaining_capacity()];
s.push(1)?;
assert_eq![2, s.remaining_capacity()];
Source

pub fn as_slice(&self) -> &[T]

Returns the stack as a shared slice.

§Examples
let s = StackUsize::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];
Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the stack as an exclusive slice.

§Examples
let mut s = StackUsize::<_, 3>::from([1, 2, 3]);
assert_eq![s.as_mut_slice(), &mut [1, 2, 3]];
Source

pub const fn clear(&mut self)

Clears the stack.

( 1 2 3 -- )

§Examples
let mut s = StackUsize::<_, 8>::from([1, 2, 3, 4]);
s.clear();
assert![s.is_empty()];
Source

pub fn push(&mut self, element: T) -> Result<(), NotEnoughSpace>

Pushes a new element to the top of the stack.

( 1 -- 1 2 )

§Errors

Returns NotEnoughSpace if the stack is full.

§Examples
let mut s = StackUsize::<_, 2>::default();
s.push(1)?;
s.push(2)?;
assert![s.push(3).is_err()];
assert_eq![s.as_slice(), &[1, 2]];
Source

pub fn pop(&mut self) -> Result<T, NotEnoughElements>

Available on crate feature unsafe_ptr or Clone only.

Pops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackUsize::<_, 2>::from([1, 2]);
assert_eq![2, s.pop()?];
assert_eq![1, s.pop()?];
assert![s.is_empty()];
§Features

It’s depends on T: Clone, unless the unsafe_ptr feature is enabled.

Source

pub fn peek(&self) -> Result<&T, NotEnoughElements>

Peeks the top stack element.

( 1 -- 1 )

Returns a shared reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let s = StackUsize::<_, 2>::from([1, 2]);
assert_eq![s.peek(), Ok(&2)];
Source

pub fn peek_mut(&mut self) -> Result<&mut T, NotEnoughElements>

Mutably peeks the top stack element.

( 1 -- 1 )

Returns an exclusive reference to the top stack element.

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackUsize::<_, 2>::from([1, 2]);
assert_eq![s.peek_mut(), Ok(&mut 2)];
Source

pub fn peek_nth(&self, nth: usize) -> Result<&T, NotEnoughElements>

Peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns a shared reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let s = StackUsize::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth(0), Ok(&5)];
assert_eq![s.peek_nth(4), Ok(&1)];
Source

pub fn peek_nth_mut(&mut self, nth: usize) -> Result<&mut T, NotEnoughElements>

Mutably peeks the nth element from the top of the stack.

( 1 -- 1 )

Returns an exclusive reference to the nth element, starting from 0 for the top, 1 for the next-of-stack, etc.

§Errors

Returns NotEnoughElements if the stack has not enough elements.

§Examples
let mut s = StackUsize::<_, 5>::from([1, 2, 3, 4, 5]);
assert_eq![s.peek_nth_mut(0), Ok(&mut 5)];
assert_eq![s.peek_nth_mut(4), Ok(&mut 1)];
Source

pub fn drop(&mut self) -> Result<(), NotEnoughElements>

Drops the top stack element.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackUsize::<_, 2>::from([1, 2]);
s.drop();
assert_eq![s.as_slice(), &[1]];
Source

pub fn drop_n(&mut self, n: usize) -> Result<(), NotEnoughElements>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least n elements.

§Examples
let mut s = StackUsize::<_, 4>::from([1, 2, 3, 4]);
s.drop_n(3);
assert_eq![s.as_slice(), &[1]];
Source

pub fn nip(&mut self) -> Result<(), NotEnoughElements>

Drops the next of stack element.

( 1 2 -- 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackUsize::<_, 2>::from([1, 2]);
s.nip();
assert_eq![s.as_slice(), &[2]];
Source

pub fn nip2(&mut self) -> Result<(), NotEnoughElements>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackUsize::<_, 8>::from([1, 2, 3, 4]);
s.nip2();
assert_eq![s.as_slice(), &[3, 4]];
Source

pub fn swap(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two stack elements.

( 1 2 -- 2 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 2 elements.

§Examples
let mut s = StackUsize::<_, 2>::from([1, 2]);
s.swap();
assert_eq![s.as_slice(), &[2, 1]];
Source

pub fn swap2(&mut self) -> Result<(), NotEnoughElements>

Swaps the top two pair stack elements.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 4 elements.

§Examples
let mut s = StackUsize::<_, 4>::from([1, 2, 3, 4]);
s.swap2();
assert_eq![s.as_slice(), &[3, 4, 1, 2]];
Source

pub fn rot(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackUsize::<_, 3>::from(['a', 'b', 'c']);
s.rot()?;
assert_eq![s.as_slice(), &['b', 'c', 'a']];
Source

pub fn rot_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 3 elements.

§Examples
let mut s = StackUsize::<_, 3>::from(['a', 'b', 'c']);
s.rot_cc()?;
assert_eq![s.as_slice(), &['c', 'a', 'b']];
Source

pub fn rot2(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackUsize::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source

pub fn rot2_cc(&mut self) -> Result<(), NotEnoughElements>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns NotEnoughElements if the stack doesn’t contain at least 6 elements.

§Examples
let mut s = StackUsize::<_, 6>::from(['a', 'b', 'c', 'd', 'e', 'f']);
s.rot2()?;
assert_eq![s.as_slice(), &['c', 'd', 'e', 'f', 'a', 'b']];
Source§

impl<T: Clone, const CAP: usize, S: Storage> Stack<T, CAP, usize, S>

§Operations depending on T: Clone

Every method is const and returns Own<Self, V>.

Source

pub fn dup(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns DataNotEnough::Elements if the stack is empty or DataNotEnough::Space if the stack is full.

§Examples
let mut s = StackUsize::<_, 2>::from([1]);
s.dup()?;
assert_eq![&[1, 1], s.as_slice()];
Source

pub fn dup2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackUsize::<_, 5>::from([1, 2]);
s.dup2()?;
assert_eq![&[1, 2, 1, 2], s.as_slice()];
Source

pub fn over(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackUsize::<_, 3>::from([1, 2]);
s.over()?;
assert_eq![&[1, 2, 1], s.as_slice()];
Source

pub fn over2(&mut self) -> Result<(), DataNotEnough>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackUsize::<_, 6>::from([1, 2, 3, 4]);
s.over2()?;
assert_eq![&[1, 2, 3, 4, 1, 2], s.as_slice()];
Source

pub fn tuck(&mut self) -> Result<(), DataNotEnough>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 2 elements, or DataNotEnough::Space if it doesn’t have enough space for 1 extra element.

§Examples
let mut s = StackUsize::<_, 3>::from([1, 2]);
s.tuck()?;
assert_eq![&[2, 1, 2], s.as_slice()];
Source

pub fn tuck2(&mut self) -> Result<(), DataNotEnough>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns DataNotEnough::Elements if the stack doesn’t have at least 4 elements, or DataNotEnough::Space if it doesn’t have enough space for 2 extra elements.

§Examples
let mut s = StackUsize::<_, 6>::from([1, 2, 3, 4]);
s.tuck2()?;
assert_eq![&[3, 4, 1, 2, 3, 4], s.as_slice()];
Source

pub fn to_vec(&self) -> Vec<T>

Available on crate feature alloc only.

Returns the stacked elements as a vector.

§Examples
let mut s = StackUsize::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_vec(), vec![1, 2, 3, 4, 5]];
Source

pub fn to_array<const LEN: usize>(&self) -> Option<[T; LEN]>

Returns some LEN stacked elements as an array, or None if the stack is empty, or there are not at least LEN elements.

This is a non alloc alternative method to to_vec.

§Panics

Panics if the new LEN sized array can’t be allocated.

§Examples
let mut s = StackUsize::<_, 5>::from([1, 2]);
s.push(3)?;
s.push(4)?;
s.push(5)?;
assert_eq![s.to_array::<5>(), Some([1, 2, 3, 4, 5])];
§Features

Makes use of the unsafe_array feature if enabled.

Source§

impl<T, const CAP: usize, S: Storage> Stack<T, CAP, usize, S>

Source

pub const fn iter(&self) -> StackIter<'_, T, CAP, usize, S>

Returns an iterator.

Source

pub fn extend<I>(&mut self, iterator: I) -> Result<(), NotEnoughSpace>
where I: IntoIterator<Item = T>,

Extends the stack from an iterator.

§Errors

Returns NotEnoughSpace if the stack becomes full before the iterator finishes.

§Examples
let mut s = StackUsize::<_, 5>::default();
s.extend([1, 2, 3]);
assert_eq![s.as_slice(), &[1, 2, 3]];

s.extend([4, 5, 6, 7, 8]);
assert_eq![s.as_slice(), &[1, 2, 3, 4, 5]];
Source§

impl<T: PartialEq, const CAP: usize, S: Storage> Stack<T, CAP, usize, S>

Source

pub fn contains(&self, element: &T) -> bool

Returns true if the stack contains element.

§Examples
let s = StackUsize::<_, 6>::from([5, 78, 42, 33, 9]);

assert![s.contains(&9)];
assert![!s.contains(&8)];
Source§

impl<T: Default, const CAP: usize, S: Storage> Stack<T, CAP, usize, S>

Source

pub fn drop_replace_default(&mut self) -> Result<(), NotEnoughElements>

Drops the top of stack element, replacing the underlying data with the default value.

( 1 2 -- 1 )

§Errors

Returns NotEnoughElements if the stack is empty.

§Examples
let mut s = StackUsize::<_, 2>::from([1, 2]);
s.drop_replace_default();
assert_eq![s.as_slice(), &[1]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u8, Bare>

§Chainable const

operations depending on T: Copy

Every method is const and returns Own<Self, V>.

Source

pub const fn own_new(element: T) -> Own<Result<Self, MismatchedCapacity>, ()>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > u8::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU8<i32, 16> = StackU8::own_new(0).s_const_unwrap().s;
Source

pub const fn own_clear(self) -> Own<Self, ()>

Clears the stack in compile-time.

( 1 2 3 -- )

§Examples
const S: StackU8<i32, 3> = StackU8::from_array_copy([1, 2, 3]).own_clear().s;
assert![S.is_empty()];
Source

pub const fn own_push(self, element: T) -> Own<Self, Result<(), NotEnoughSpace>>

Pushes a new element to the top of the stack in compile-time.

( 1 -- 1 2 )

§Errors

Returns Own<S,NotEnoughSpace> if the stack is full.

§Examples
const S: StackU8<i32, 2> = StackU8::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s
    .own_push(2).v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 2]];
assert![S.own_push(3).v.is_err_and(|e| matches![e, NotEnoughSpace])];
Source

pub const fn own_push_unchecked(self, element: T) -> Own<Self, ()>

Pushes a new element to the top of the stack in compile-time, unchecked version.

( 1 -- 1 2 )

§Panics

Panics if the stack is full.

§Examples
const S: StackU8<i32, 2> = StackU8::own_new(0).s_const_unwrap().s
    .own_push_unchecked(1).s.own_push_unchecked(2).s;
assert_eq![S.as_slice(), &[1, 2]];
Source

pub const fn own_pop(self) -> Own<Self, Result<T, NotEnoughElements>>

Pops the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackU8<i32, 3>, Result<i32, NotEnoughElements>> =
   StackU8::from_array_copy([1, 2, 3]).own_pop();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&Ok(3));
Source

pub const fn own_pop_unchecked(self) -> Own<Self, T>

Pops the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackU8<i32, 3>, i32> =
   StackU8::from_array_copy([1, 2, 3]).own_pop_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&3);
Source

pub const fn own_peek(self) -> Own<Self, Result<T, NotEnoughElements>>

Peeks the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackU8<i32, 3>, Result<i32, NotEnoughElements>> =
  StackU8::from_array_copy([1, 2, 3]).own_peek();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&Ok(3));
Source

pub const fn own_peek_unchecked(self) -> Own<Self, T>

Peeks the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackU8<i32, 3>, i32> = StackU8::from_array_copy([1, 2, 3])
    .own_peek_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&3);
Source

pub const fn own_drop(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top stack element in compile-time.

( 1 2 -- 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack is empty.

§Examples
const S: StackU8<i32, 2> = StackU8::from_array_copy([1, 2])
    .own_drop().v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];

const T: StackU8<i32, 2> = StackU8::own_new(0).s_const_unwrap().s
    .own_drop().v_assert_err().s;
assert![T.is_empty()];
Source

pub const fn own_drop_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements, unchecked version.

( 1 2 -- 1 )

§Panics

Panics if the stack is empty.

§Examples
const S: StackU8<i32, 2> = StackU8::from_array_copy([1, 2])
    .own_drop_unchecked().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n(self, n: u8) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least n elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([1, 2, 3, 4])
    .own_drop_n(3).v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n_unchecked(self, n: u8) -> Own<Self, ()>

Drops the top n stack elements, unchecked version.

( 1 2 3 4 -- 1 ) for n == 3

§Panics

Panics if the stack doesn’t contain at least n elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([1, 2, 3, 4])
    .own_drop_n_unchecked(3).s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_nip(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the next of stack element in compile-time.

( 1 2 -- 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU8<i32, 2> = StackU8::from_array_copy([1, 2])
    .own_nip().v_assert_ok().s;
assert_eq![S.as_slice(), &[2]];

const T: StackU8<i32, 2> = StackU8::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s.own_nip().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_nip_unchecked(self) -> Own<Self, ()>

Drops the next of stack element in compile-time, unchecked version.

( 1 2 -- 2 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU8<i32, 2> = StackU8::from_array_copy([1, 2])
    .own_nip_unchecked().s;
assert_eq![S.as_slice(), &[2]];
Source

pub const fn own_nip2(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([1, 2, 3, 4])
    .own_nip2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_nip2_unchecked(self) -> Own<Self, ()>

Drops the pair of next stack elements, unchecked version.

( 1 2 3 4 -- 3 4 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([1, 2, 3, 4])
    .own_nip2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_swap(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two stack elements in compile-time.

( 1 2 -- 2 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU8<i32, 2> = StackU8::from_array_copy([1, 2])
    .own_swap().v_assert_ok().s;
assert_eq![S.as_slice(), &[2, 1]];

const T: StackU8<i32, 1> = StackU8::from_array_copy([1])
    .own_swap().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_swap_unchecked(self) -> Own<Self, ()>

Swaps the top two stack elements in compile-time, unchecked version.

( 1 2 -- 2 1 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU8<i32, 2> = StackU8::from_array_copy([1, 2])
    .own_swap_unchecked().s;
assert_eq![S.as_slice(), &[2, 1]];
Source

pub const fn own_swap2(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two pair stack elements in compile-time.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([1, 2, 3, 4])
    .own_swap2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];

const T: StackU8<i32, 3> = StackU8::from_array_copy([1, 2, 3])
    .own_swap2().v_assert_err().s;
assert_eq![T.as_slice(), &[1, 2, 3]];
Source

pub const fn own_swap2_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements in compile-time, unchecked version.

( 1 2 3 4 -- 3 4 1 2 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([1, 2, 3, 4])
    .own_swap2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];
Source

pub const fn own_rot(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 3])
    .own_rot().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, clockwise, unchecked version.

( 1 2 3 -- 2 3 1 )

§Panics

Panics if the stack doesn’t contain at least 6 elements. if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 3])
    .own_rot_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 3])
    .own_rot_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot_cc_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, counter-clockwise, unchecked version.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 3])
    .own_rot_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot2(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_rot2_cc_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, counter-clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_dup(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack is empty or Own<self,DataNotEnough::Space> if the stack is full.

§Examples
const S: StackU8<i32, 3> = StackU8::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup().v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup_unchecked(self) -> Own<Self, ()>

Duplicates the top stack element, unchecked version.

( 1 -- 1 1 )

§Panics

Panics if the stack is either empty or full.

§Examples
const S: StackU8<i32, 3> = StackU8::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup_unchecked().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 6> = StackU8::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_dup2_unchecked(self) -> Own<Self, ()>

Duplicates the top stack pair of elements, unchecked version.

( 1 2 -- 1 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 6> = StackU8::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_over(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_over2_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_tuck(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck_unchecked(self) -> Own<Self, ()>

Duplicates the top element before the next of stack element, unchecked version.

( 1 2 -- 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackU8<i32, 4> = StackU8::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source

pub const fn own_tuck2_unchecked(self) -> Own<Self, ()>

Duplicates the top pair of elements before the next of stack pair of elements, unchecked version.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU8<i32, 7> = StackU8::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u16, Bare>

§Chainable const

operations depending on T: Copy

Every method is const and returns Own<Self, V>.

Source

pub const fn own_new(element: T) -> Own<Result<Self, MismatchedCapacity>, ()>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > u16::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU16<i32, 16> = StackU16::own_new(0).s_const_unwrap().s;
Source

pub const fn own_clear(self) -> Own<Self, ()>

Clears the stack in compile-time.

( 1 2 3 -- )

§Examples
const S: StackU16<i32, 3> = StackU16::from_array_copy([1, 2, 3]).own_clear().s;
assert![S.is_empty()];
Source

pub const fn own_push(self, element: T) -> Own<Self, Result<(), NotEnoughSpace>>

Pushes a new element to the top of the stack in compile-time.

( 1 -- 1 2 )

§Errors

Returns Own<S,NotEnoughSpace> if the stack is full.

§Examples
const S: StackU16<i32, 2> = StackU16::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s
    .own_push(2).v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 2]];
assert![S.own_push(3).v.is_err_and(|e| matches![e, NotEnoughSpace])];
Source

pub const fn own_push_unchecked(self, element: T) -> Own<Self, ()>

Pushes a new element to the top of the stack in compile-time, unchecked version.

( 1 -- 1 2 )

§Panics

Panics if the stack is full.

§Examples
const S: StackU16<i32, 2> = StackU16::own_new(0).s_const_unwrap().s
    .own_push_unchecked(1).s.own_push_unchecked(2).s;
assert_eq![S.as_slice(), &[1, 2]];
Source

pub const fn own_pop(self) -> Own<Self, Result<T, NotEnoughElements>>

Pops the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackU16<i32, 3>, Result<i32, NotEnoughElements>> =
   StackU16::from_array_copy([1, 2, 3]).own_pop();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&Ok(3));
Source

pub const fn own_pop_unchecked(self) -> Own<Self, T>

Pops the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackU16<i32, 3>, i32> =
   StackU16::from_array_copy([1, 2, 3]).own_pop_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&3);
Source

pub const fn own_peek(self) -> Own<Self, Result<T, NotEnoughElements>>

Peeks the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackU16<i32, 3>, Result<i32, NotEnoughElements>> =
  StackU16::from_array_copy([1, 2, 3]).own_peek();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&Ok(3));
Source

pub const fn own_peek_unchecked(self) -> Own<Self, T>

Peeks the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackU16<i32, 3>, i32> = StackU16::from_array_copy([1, 2, 3])
    .own_peek_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&3);
Source

pub const fn own_drop(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top stack element in compile-time.

( 1 2 -- 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack is empty.

§Examples
const S: StackU16<i32, 2> = StackU16::from_array_copy([1, 2])
    .own_drop().v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];

const T: StackU16<i32, 2> = StackU16::own_new(0).s_const_unwrap().s
    .own_drop().v_assert_err().s;
assert![T.is_empty()];
Source

pub const fn own_drop_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements, unchecked version.

( 1 2 -- 1 )

§Panics

Panics if the stack is empty.

§Examples
const S: StackU16<i32, 2> = StackU16::from_array_copy([1, 2])
    .own_drop_unchecked().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n( self, n: u16, ) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least n elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([1, 2, 3, 4])
    .own_drop_n(3).v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n_unchecked(self, n: u16) -> Own<Self, ()>

Drops the top n stack elements, unchecked version.

( 1 2 3 4 -- 1 ) for n == 3

§Panics

Panics if the stack doesn’t contain at least n elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([1, 2, 3, 4])
    .own_drop_n_unchecked(3).s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_nip(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the next of stack element in compile-time.

( 1 2 -- 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU16<i32, 2> = StackU16::from_array_copy([1, 2])
    .own_nip().v_assert_ok().s;
assert_eq![S.as_slice(), &[2]];

const T: StackU16<i32, 2> = StackU16::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s.own_nip().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_nip_unchecked(self) -> Own<Self, ()>

Drops the next of stack element in compile-time, unchecked version.

( 1 2 -- 2 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU16<i32, 2> = StackU16::from_array_copy([1, 2])
    .own_nip_unchecked().s;
assert_eq![S.as_slice(), &[2]];
Source

pub const fn own_nip2(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([1, 2, 3, 4])
    .own_nip2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_nip2_unchecked(self) -> Own<Self, ()>

Drops the pair of next stack elements, unchecked version.

( 1 2 3 4 -- 3 4 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([1, 2, 3, 4])
    .own_nip2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_swap(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two stack elements in compile-time.

( 1 2 -- 2 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU16<i32, 2> = StackU16::from_array_copy([1, 2])
    .own_swap().v_assert_ok().s;
assert_eq![S.as_slice(), &[2, 1]];

const T: StackU16<i32, 1> = StackU16::from_array_copy([1])
    .own_swap().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_swap_unchecked(self) -> Own<Self, ()>

Swaps the top two stack elements in compile-time, unchecked version.

( 1 2 -- 2 1 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU16<i32, 2> = StackU16::from_array_copy([1, 2])
    .own_swap_unchecked().s;
assert_eq![S.as_slice(), &[2, 1]];
Source

pub const fn own_swap2(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two pair stack elements in compile-time.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([1, 2, 3, 4])
    .own_swap2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];

const T: StackU16<i32, 3> = StackU16::from_array_copy([1, 2, 3])
    .own_swap2().v_assert_err().s;
assert_eq![T.as_slice(), &[1, 2, 3]];
Source

pub const fn own_swap2_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements in compile-time, unchecked version.

( 1 2 3 4 -- 3 4 1 2 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([1, 2, 3, 4])
    .own_swap2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];
Source

pub const fn own_rot(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 3])
    .own_rot().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, clockwise, unchecked version.

( 1 2 3 -- 2 3 1 )

§Panics

Panics if the stack doesn’t contain at least 6 elements. if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 3])
    .own_rot_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 3])
    .own_rot_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot_cc_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, counter-clockwise, unchecked version.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 3])
    .own_rot_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot2(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_rot2_cc_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, counter-clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_dup(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack is empty or Own<self,DataNotEnough::Space> if the stack is full.

§Examples
const S: StackU16<i32, 3> = StackU16::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup().v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup_unchecked(self) -> Own<Self, ()>

Duplicates the top stack element, unchecked version.

( 1 -- 1 1 )

§Panics

Panics if the stack is either empty or full.

§Examples
const S: StackU16<i32, 3> = StackU16::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup_unchecked().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 6> = StackU16::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_dup2_unchecked(self) -> Own<Self, ()>

Duplicates the top stack pair of elements, unchecked version.

( 1 2 -- 1 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 6> = StackU16::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_over(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_over2_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_tuck(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck_unchecked(self) -> Own<Self, ()>

Duplicates the top element before the next of stack element, unchecked version.

( 1 2 -- 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackU16<i32, 4> = StackU16::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source

pub const fn own_tuck2_unchecked(self) -> Own<Self, ()>

Duplicates the top pair of elements before the next of stack pair of elements, unchecked version.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU16<i32, 7> = StackU16::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, u32, Bare>

§Chainable const

operations depending on T: Copy

Every method is const and returns Own<Self, V>.

Source

pub const fn own_new(element: T) -> Own<Result<Self, MismatchedCapacity>, ()>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > u32::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackU32<i32, 16> = StackU32::own_new(0).s_const_unwrap().s;
Source

pub const fn own_clear(self) -> Own<Self, ()>

Clears the stack in compile-time.

( 1 2 3 -- )

§Examples
const S: StackU32<i32, 3> = StackU32::from_array_copy([1, 2, 3]).own_clear().s;
assert![S.is_empty()];
Source

pub const fn own_push(self, element: T) -> Own<Self, Result<(), NotEnoughSpace>>

Pushes a new element to the top of the stack in compile-time.

( 1 -- 1 2 )

§Errors

Returns Own<S,NotEnoughSpace> if the stack is full.

§Examples
const S: StackU32<i32, 2> = StackU32::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s
    .own_push(2).v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 2]];
assert![S.own_push(3).v.is_err_and(|e| matches![e, NotEnoughSpace])];
Source

pub const fn own_push_unchecked(self, element: T) -> Own<Self, ()>

Pushes a new element to the top of the stack in compile-time, unchecked version.

( 1 -- 1 2 )

§Panics

Panics if the stack is full.

§Examples
const S: StackU32<i32, 2> = StackU32::own_new(0).s_const_unwrap().s
    .own_push_unchecked(1).s.own_push_unchecked(2).s;
assert_eq![S.as_slice(), &[1, 2]];
Source

pub const fn own_pop(self) -> Own<Self, Result<T, NotEnoughElements>>

Pops the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackU32<i32, 3>, Result<i32, NotEnoughElements>> =
   StackU32::from_array_copy([1, 2, 3]).own_pop();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&Ok(3));
Source

pub const fn own_pop_unchecked(self) -> Own<Self, T>

Pops the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackU32<i32, 3>, i32> =
   StackU32::from_array_copy([1, 2, 3]).own_pop_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&3);
Source

pub const fn own_peek(self) -> Own<Self, Result<T, NotEnoughElements>>

Peeks the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackU32<i32, 3>, Result<i32, NotEnoughElements>> =
  StackU32::from_array_copy([1, 2, 3]).own_peek();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&Ok(3));
Source

pub const fn own_peek_unchecked(self) -> Own<Self, T>

Peeks the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackU32<i32, 3>, i32> = StackU32::from_array_copy([1, 2, 3])
    .own_peek_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&3);
Source

pub const fn own_drop(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top stack element in compile-time.

( 1 2 -- 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack is empty.

§Examples
const S: StackU32<i32, 2> = StackU32::from_array_copy([1, 2])
    .own_drop().v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];

const T: StackU32<i32, 2> = StackU32::own_new(0).s_const_unwrap().s
    .own_drop().v_assert_err().s;
assert![T.is_empty()];
Source

pub const fn own_drop_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements, unchecked version.

( 1 2 -- 1 )

§Panics

Panics if the stack is empty.

§Examples
const S: StackU32<i32, 2> = StackU32::from_array_copy([1, 2])
    .own_drop_unchecked().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n( self, n: u32, ) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least n elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([1, 2, 3, 4])
    .own_drop_n(3).v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n_unchecked(self, n: u32) -> Own<Self, ()>

Drops the top n stack elements, unchecked version.

( 1 2 3 4 -- 1 ) for n == 3

§Panics

Panics if the stack doesn’t contain at least n elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([1, 2, 3, 4])
    .own_drop_n_unchecked(3).s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_nip(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the next of stack element in compile-time.

( 1 2 -- 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU32<i32, 2> = StackU32::from_array_copy([1, 2])
    .own_nip().v_assert_ok().s;
assert_eq![S.as_slice(), &[2]];

const T: StackU32<i32, 2> = StackU32::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s.own_nip().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_nip_unchecked(self) -> Own<Self, ()>

Drops the next of stack element in compile-time, unchecked version.

( 1 2 -- 2 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU32<i32, 2> = StackU32::from_array_copy([1, 2])
    .own_nip_unchecked().s;
assert_eq![S.as_slice(), &[2]];
Source

pub const fn own_nip2(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([1, 2, 3, 4])
    .own_nip2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_nip2_unchecked(self) -> Own<Self, ()>

Drops the pair of next stack elements, unchecked version.

( 1 2 3 4 -- 3 4 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([1, 2, 3, 4])
    .own_nip2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_swap(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two stack elements in compile-time.

( 1 2 -- 2 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU32<i32, 2> = StackU32::from_array_copy([1, 2])
    .own_swap().v_assert_ok().s;
assert_eq![S.as_slice(), &[2, 1]];

const T: StackU32<i32, 1> = StackU32::from_array_copy([1])
    .own_swap().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_swap_unchecked(self) -> Own<Self, ()>

Swaps the top two stack elements in compile-time, unchecked version.

( 1 2 -- 2 1 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackU32<i32, 2> = StackU32::from_array_copy([1, 2])
    .own_swap_unchecked().s;
assert_eq![S.as_slice(), &[2, 1]];
Source

pub const fn own_swap2(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two pair stack elements in compile-time.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([1, 2, 3, 4])
    .own_swap2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];

const T: StackU32<i32, 3> = StackU32::from_array_copy([1, 2, 3])
    .own_swap2().v_assert_err().s;
assert_eq![T.as_slice(), &[1, 2, 3]];
Source

pub const fn own_swap2_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements in compile-time, unchecked version.

( 1 2 3 4 -- 3 4 1 2 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([1, 2, 3, 4])
    .own_swap2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];
Source

pub const fn own_rot(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 3])
    .own_rot().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, clockwise, unchecked version.

( 1 2 3 -- 2 3 1 )

§Panics

Panics if the stack doesn’t contain at least 6 elements. if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 3])
    .own_rot_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 3])
    .own_rot_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot_cc_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, counter-clockwise, unchecked version.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 3])
    .own_rot_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot2(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_rot2_cc_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, counter-clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_dup(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack is empty or Own<self,DataNotEnough::Space> if the stack is full.

§Examples
const S: StackU32<i32, 3> = StackU32::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup().v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup_unchecked(self) -> Own<Self, ()>

Duplicates the top stack element, unchecked version.

( 1 -- 1 1 )

§Panics

Panics if the stack is either empty or full.

§Examples
const S: StackU32<i32, 3> = StackU32::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup_unchecked().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 6> = StackU32::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_dup2_unchecked(self) -> Own<Self, ()>

Duplicates the top stack pair of elements, unchecked version.

( 1 2 -- 1 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 6> = StackU32::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_over(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_over2_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_tuck(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck_unchecked(self) -> Own<Self, ()>

Duplicates the top element before the next of stack element, unchecked version.

( 1 2 -- 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackU32<i32, 4> = StackU32::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source

pub const fn own_tuck2_unchecked(self) -> Own<Self, ()>

Duplicates the top pair of elements before the next of stack pair of elements, unchecked version.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackU32<i32, 7> = StackU32::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source§

impl<T: Copy, const CAP: usize> Stack<T, CAP, usize, Bare>

§Chainable const

operations depending on T: Copy

Every method is const and returns Own<Self, V>.

Source

pub const fn own_new(element: T) -> Own<Result<Self, MismatchedCapacity>, ()>

Returns an empty stack, allocated in the stack, copying element to fill the remaining free data.

§Errors

Returns MismatchedCapacity if CAP > usize::MAX or if CAP > isize::MAX / size_of::<T>().

§Examples
const S: StackUsize<i32, 16> = StackUsize::own_new(0).s_const_unwrap().s;
Source

pub const fn own_clear(self) -> Own<Self, ()>

Clears the stack in compile-time.

( 1 2 3 -- )

§Examples
const S: StackUsize<i32, 3> = StackUsize::from_array_copy([1, 2, 3]).own_clear().s;
assert![S.is_empty()];
Source

pub const fn own_push(self, element: T) -> Own<Self, Result<(), NotEnoughSpace>>

Pushes a new element to the top of the stack in compile-time.

( 1 -- 1 2 )

§Errors

Returns Own<S,NotEnoughSpace> if the stack is full.

§Examples
const S: StackUsize<i32, 2> = StackUsize::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s
    .own_push(2).v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 2]];
assert![S.own_push(3).v.is_err_and(|e| matches![e, NotEnoughSpace])];
Source

pub const fn own_push_unchecked(self, element: T) -> Own<Self, ()>

Pushes a new element to the top of the stack in compile-time, unchecked version.

( 1 -- 1 2 )

§Panics

Panics if the stack is full.

§Examples
const S: StackUsize<i32, 2> = StackUsize::own_new(0).s_const_unwrap().s
    .own_push_unchecked(1).s.own_push_unchecked(2).s;
assert_eq![S.as_slice(), &[1, 2]];
Source

pub const fn own_pop(self) -> Own<Self, Result<T, NotEnoughElements>>

Pops the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackUsize<i32, 3>, Result<i32, NotEnoughElements>> =
   StackUsize::from_array_copy([1, 2, 3]).own_pop();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&Ok(3));
Source

pub const fn own_pop_unchecked(self) -> Own<Self, T>

Pops the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackUsize<i32, 3>, i32> =
   StackUsize::from_array_copy([1, 2, 3]).own_pop_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2]).v_assert_eq(&3);
Source

pub const fn own_peek(self) -> Own<Self, Result<T, NotEnoughElements>>

Peeks the top stack element in compile-time.

( 1 2 3 -- 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack is empty.

§Examples
const S: Own<StackUsize<i32, 3>, Result<i32, NotEnoughElements>> =
  StackUsize::from_array_copy([1, 2, 3]).own_peek();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&Ok(3));
Source

pub const fn own_peek_unchecked(self) -> Own<Self, T>

Peeks the top stack element in compile-time, unchecked version.

( 1 2 3 -- 1 2 )

§Panics

Panics if the stack is empty.

§Examples
const S: Own<StackUsize<i32, 3>, i32> = StackUsize::from_array_copy([1, 2, 3])
    .own_peek_unchecked();
S.s_assert(|s| s.as_slice() == &[1, 2, 3]).v_assert_eq(&3);
Source

pub const fn own_drop(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top stack element in compile-time.

( 1 2 -- 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack is empty.

§Examples
const S: StackUsize<i32, 2> = StackUsize::from_array_copy([1, 2])
    .own_drop().v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];

const T: StackUsize<i32, 2> = StackUsize::own_new(0).s_const_unwrap().s
    .own_drop().v_assert_err().s;
assert![T.is_empty()];
Source

pub const fn own_drop_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements, unchecked version.

( 1 2 -- 1 )

§Panics

Panics if the stack is empty.

§Examples
const S: StackUsize<i32, 2> = StackUsize::from_array_copy([1, 2])
    .own_drop_unchecked().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n( self, n: usize, ) -> Own<Self, Result<(), NotEnoughElements>>

Drops the top n stack elements.

( 1 2 3 4 -- 1 ) for n == 3

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least n elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([1, 2, 3, 4])
    .own_drop_n(3).v_assert_ok().s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_drop_n_unchecked(self, n: usize) -> Own<Self, ()>

Drops the top n stack elements, unchecked version.

( 1 2 3 4 -- 1 ) for n == 3

§Panics

Panics if the stack doesn’t contain at least n elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([1, 2, 3, 4])
    .own_drop_n_unchecked(3).s;
assert_eq![S.as_slice(), &[1]];
Source

pub const fn own_nip(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the next of stack element in compile-time.

( 1 2 -- 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackUsize<i32, 2> = StackUsize::from_array_copy([1, 2])
    .own_nip().v_assert_ok().s;
assert_eq![S.as_slice(), &[2]];

const T: StackUsize<i32, 2> = StackUsize::own_new(0).s_const_unwrap().s
    .own_push(1).v_assert_ok().s.own_nip().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_nip_unchecked(self) -> Own<Self, ()>

Drops the next of stack element in compile-time, unchecked version.

( 1 2 -- 2 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackUsize<i32, 2> = StackUsize::from_array_copy([1, 2])
    .own_nip_unchecked().s;
assert_eq![S.as_slice(), &[2]];
Source

pub const fn own_nip2(self) -> Own<Self, Result<(), NotEnoughElements>>

Drops the pair of next stack elements.

( 1 2 3 4 -- 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([1, 2, 3, 4])
    .own_nip2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_nip2_unchecked(self) -> Own<Self, ()>

Drops the pair of next stack elements, unchecked version.

( 1 2 3 4 -- 3 4 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([1, 2, 3, 4])
    .own_nip2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4]];
Source

pub const fn own_swap(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two stack elements in compile-time.

( 1 2 -- 2 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackUsize<i32, 2> = StackUsize::from_array_copy([1, 2])
    .own_swap().v_assert_ok().s;
assert_eq![S.as_slice(), &[2, 1]];

const T: StackUsize<i32, 1> = StackUsize::from_array_copy([1])
    .own_swap().v_assert_err().s;
assert_eq![T.as_slice(), &[1]];
Source

pub const fn own_swap_unchecked(self) -> Own<Self, ()>

Swaps the top two stack elements in compile-time, unchecked version.

( 1 2 -- 2 1 )

§Panics

Panics if the stack doesn’t contain at least 2 elements.

§Examples
const S: StackUsize<i32, 2> = StackUsize::from_array_copy([1, 2])
    .own_swap_unchecked().s;
assert_eq![S.as_slice(), &[2, 1]];
Source

pub const fn own_swap2(self) -> Own<Self, Result<(), NotEnoughElements>>

Swaps the top two pair stack elements in compile-time.

( 1 2 3 4 -- 3 4 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([1, 2, 3, 4])
    .own_swap2().v_assert_ok().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];

const T: StackUsize<i32, 3> = StackUsize::from_array_copy([1, 2, 3])
    .own_swap2().v_assert_err().s;
assert_eq![T.as_slice(), &[1, 2, 3]];
Source

pub const fn own_swap2_unchecked(self) -> Own<Self, ()>

Swaps the top two pair stack elements in compile-time, unchecked version.

( 1 2 3 4 -- 3 4 1 2 )

§Panics

Panics if the stack doesn’t contain at least 4 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([1, 2, 3, 4])
    .own_swap2_unchecked().s;
assert_eq![S.as_slice(), &[3, 4, 1, 2]];
Source

pub const fn own_rot(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, clockwise.

( 1 2 3 -- 2 3 1 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 3])
    .own_rot().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, clockwise, unchecked version.

( 1 2 3 -- 2 3 1 )

§Panics

Panics if the stack doesn’t contain at least 6 elements. if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 3])
    .own_rot_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 3, 1]];
Source

pub const fn own_rot_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top three stack elements, counter-clockwise.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 3])
    .own_rot_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot_cc_unchecked(self) -> Own<Self, ()>

Rotates the top three stack elements, counter-clockwise, unchecked version.

( 1 2 3 -- 3 1 2 )

§Errors

Returns Own<S,NotEnoughElements> if the stack doesn’t contain at least 3 elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 3])
    .own_rot_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 1, 2]];
Source

pub const fn own_rot2(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, clockwise, two times.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 3 4 5 6 1 2 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 5, 6, 1, 2]];
Source

pub const fn own_rot2_cc(self) -> Own<Self, Result<(), NotEnoughElements>>

Rotates the top six stack elements, counter-clockwise, two times.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Errors

Returns Own<self,NotEnoughElements> if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_rot2_cc_unchecked(self) -> Own<Self, ()>

Rotates the top six stack elements, counter-clockwise, two times, unchecked version.

( 1 2 3 4 5 6 -- 5 6 1 2 3 4 )

§Panics

Panics if the stack doesn’t contain at least 6 elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 5, 6])
    .own_rot2_cc_unchecked().s;
assert_eq![S.as_slice(), &[0, 5, 6, 1, 2, 3, 4]];
Source

pub const fn own_dup(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack element.

( 1 -- 1 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack is empty or Own<self,DataNotEnough::Space> if the stack is full.

§Examples
const S: StackUsize<i32, 3> = StackUsize::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup().v_assert_ok().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup_unchecked(self) -> Own<Self, ()>

Duplicates the top stack element, unchecked version.

( 1 -- 1 1 )

§Panics

Panics if the stack is either empty or full.

§Examples
const S: StackUsize<i32, 3> = StackUsize::own_new(0).s_const_unwrap().s
    .own_push(1).s.own_dup_unchecked().s;
assert_eq![S.as_slice(), &[1, 1]];
Source

pub const fn own_dup2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top stack pair of elements.

( 1 2 -- 1 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 6> = StackUsize::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_dup2_unchecked(self) -> Own<Self, ()>

Duplicates the top stack pair of elements, unchecked version.

( 1 2 -- 1 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 6> = StackUsize::from_array_copy([0, 1, 2, 0, 0, 0])
    .own_drop_n(3).s.own_dup2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1, 2]];
Source

pub const fn own_over(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack element to the top.

( 1 2 -- 1 2 1 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_over_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 1]];
Source

pub const fn own_over2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_over2_unchecked(self) -> Own<Self, ()>

Duplicates the next of stack pair of elements to the top.

( 1 2 3 4 -- 1 2 3 4 1 2 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_over2_unchecked().s;
assert_eq![S.as_slice(), &[0, 1, 2, 3, 4, 1, 2]];
Source

pub const fn own_tuck(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top element before the next of stack element.

( 1 2 -- 2 1 2 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 2 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck().v_assert_ok().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck_unchecked(self) -> Own<Self, ()>

Duplicates the top element before the next of stack element, unchecked version.

( 1 2 -- 2 1 2 )

§Panics

Panics if the stack doesn’t have at least 2 elements, or if it doesn’t have enough space for 1 extra elements.

§Examples
const S: StackUsize<i32, 4> = StackUsize::from_array_copy([0, 1, 2, 0])
    .own_drop().s.own_tuck_unchecked().s;
assert_eq![S.as_slice(), &[0, 2, 1, 2]];
Source

pub const fn own_tuck2(self) -> Own<Self, Result<(), DataNotEnough>>

Duplicates the top pair of elements before the next of stack pair of elements.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Errors

Returns Own<self,DataNotEnough::Elements> if the stack doesn’t have at least 4 elements, or Own<self,DataNotEnough::Space> if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];
Source

pub const fn own_tuck2_unchecked(self) -> Own<Self, ()>

Duplicates the top pair of elements before the next of stack pair of elements, unchecked version.

( 1 2 3 4 -- 3 4 1 2 3 4 )

§Panics

Panics if the stack doesn’t have at least 4 elements, or if it doesn’t have enough space for 2 extra elements.

§Examples
const S: StackUsize<i32, 7> = StackUsize::from_array_copy([0, 1, 2, 3, 4, 0, 0])
    .own_drop_n(2).s.own_tuck2_unchecked().s;
assert_eq![S.as_slice(), &[0, 3, 4, 1, 2, 3, 4]];

Trait Implementations§

Source§

impl<T, const CAP: usize, IDX, S: Storage> Archive for Stack<T, CAP, IDX, S>
where Array<T, CAP, S>: Archive, IDX: Archive,

Source§

type Archived = ArchivedStack<T, CAP, IDX, S>

The archived representation of this type. Read more
Source§

type Resolver = StackResolver<T, CAP, IDX, S>

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)

Creates the archived version of this value at the given position and writes it to the given output. Read more
§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
Source§

impl<T: Clone, const CAP: usize, IDX: Copy, S: Storage> Clone for Stack<T, CAP, IDX, S>
where S::Stored<[T; CAP]>: Clone,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ConstDefault, const CAP: usize, IDX: ConstDefault> ConstDefault for Stack<T, CAP, IDX, Bare>

Source§

const DEFAULT: Self

Returns an empty stack, allocated in the stack, using the default value to fill the remaining free data.

Source§

impl<T, const LEN: usize, S: Storage> DataCollection for Stack<T, LEN, u16, S>

Source§

type Element = T

The element type of the collection.
Source§

fn collection_capacity(&self) -> Result<usize, NotAvailable>

Returns the reserved capacity for elements in the collection.
Source§

fn collection_len(&self) -> Result<usize, NotAvailable>

Returns the current number of elements in the collection.
Source§

fn collection_is_empty(&self) -> Result<bool, NotAvailable>

Returns true if the collection is empty, false if it’s not.
Source§

fn collection_is_full(&self) -> Result<bool, NotAvailable>

Returns true if the collection is full, false if it’s not.
Source§

fn collection_contains( &self, element: Self::Element, ) -> Result<bool, NotAvailable>
where T: PartialEq,

Returns true if the collection contains the given element.
Source§

fn collection_count( &self, element: &Self::Element, ) -> Result<usize, NotAvailable>
where T: PartialEq,

Counts the number of times a given element appears in the collection.
Source§

impl<T, const LEN: usize, S: Storage> DataCollection for Stack<T, LEN, u32, S>

Source§

type Element = T

The element type of the collection.
Source§

fn collection_capacity(&self) -> Result<usize, NotAvailable>

Returns the reserved capacity for elements in the collection.
Source§

fn collection_len(&self) -> Result<usize, NotAvailable>

Returns the current number of elements in the collection.
Source§

fn collection_is_empty(&self) -> Result<bool, NotAvailable>

Returns true if the collection is empty, false if it’s not.
Source§

fn collection_is_full(&self) -> Result<bool, NotAvailable>

Returns true if the collection is full, false if it’s not.
Source§

fn collection_contains( &self, element: Self::Element, ) -> Result<bool, NotAvailable>
where T: PartialEq,

Returns true if the collection contains the given element.
Source§

fn collection_count( &self, element: &Self::Element, ) -> Result<usize, NotAvailable>
where T: PartialEq,

Counts the number of times a given element appears in the collection.
Source§

impl<T, const LEN: usize, S: Storage> DataCollection for Stack<T, LEN, u8, S>

Source§

type Element = T

The element type of the collection.
Source§

fn collection_capacity(&self) -> Result<usize, NotAvailable>

Returns the reserved capacity for elements in the collection.
Source§

fn collection_len(&self) -> Result<usize, NotAvailable>

Returns the current number of elements in the collection.
Source§

fn collection_is_empty(&self) -> Result<bool, NotAvailable>

Returns true if the collection is empty, false if it’s not.
Source§

fn collection_is_full(&self) -> Result<bool, NotAvailable>

Returns true if the collection is full, false if it’s not.
Source§

fn collection_contains( &self, element: Self::Element, ) -> Result<bool, NotAvailable>
where T: PartialEq,

Returns true if the collection contains the given element.
Source§

fn collection_count( &self, element: &Self::Element, ) -> Result<usize, NotAvailable>
where T: PartialEq,

Counts the number of times a given element appears in the collection.
Source§

impl<T, const LEN: usize, S: Storage> DataCollection for Stack<T, LEN, usize, S>

Source§

type Element = T

The element type of the collection.
Source§

fn collection_capacity(&self) -> Result<usize, NotAvailable>

Returns the reserved capacity for elements in the collection.
Source§

fn collection_len(&self) -> Result<usize, NotAvailable>

Returns the current number of elements in the collection.
Source§

fn collection_is_empty(&self) -> Result<bool, NotAvailable>

Returns true if the collection is empty, false if it’s not.
Source§

fn collection_is_full(&self) -> Result<bool, NotAvailable>

Returns true if the collection is full, false if it’s not.
Source§

fn collection_contains( &self, element: Self::Element, ) -> Result<bool, NotAvailable>
where T: PartialEq,

Returns true if the collection contains the given element.
Source§

fn collection_count( &self, element: &Self::Element, ) -> Result<usize, NotAvailable>
where T: PartialEq,

Counts the number of times a given element appears in the collection.
Source§

impl<T, const CAP: usize, S: Storage> DataStack for Stack<T, CAP, u16, S>

Source§

fn stack_pop( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements>

Remove an element from the (back of the) stack.
Source§

fn stack_push( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace>

Add an element to the (back of the) stack.
Source§

impl<T, const CAP: usize, S: Storage> DataStack for Stack<T, CAP, u32, S>

Source§

fn stack_pop( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements>

Remove an element from the (back of the) stack.
Source§

fn stack_push( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace>

Add an element to the (back of the) stack.
Source§

impl<T, const CAP: usize, S: Storage> DataStack for Stack<T, CAP, u8, S>

Source§

fn stack_pop( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements>

Remove an element from the (back of the) stack.
Source§

fn stack_push( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace>

Add an element to the (back of the) stack.
Source§

impl<T, const CAP: usize, S: Storage> DataStack for Stack<T, CAP, usize, S>

Source§

fn stack_pop( &mut self, ) -> Result<<Self as DataCollection>::Element, NotEnoughElements>

Remove an element from the (back of the) stack.
Source§

fn stack_push( &mut self, element: <Self as DataCollection>::Element, ) -> Result<(), NotEnoughSpace>

Add an element to the (back of the) stack.
Source§

impl<T: Debug, const CAP: usize, IDX: Debug, S: Storage> Debug for Stack<T, CAP, IDX, S>
where S::Stored<[T; CAP]>: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default, const CAP: usize, IDX: Default> Default for Stack<T, CAP, IDX, Bare>

Source§

fn default() -> Self

Returns an empty stack, allocated in the stack, using the default value to fill the remaining free data.

Source§

impl<T: Default, const CAP: usize, IDX: Default> Default for Stack<T, CAP, IDX, Boxed>

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns an empty stack, allocated in the heap, using the default value to fill the remaining free data.

Source§

impl<__D: Fallible + ?Sized, T, const CAP: usize, IDX, S: Storage> Deserialize<Stack<T, CAP, IDX, S>, __D> for Archived<Stack<T, CAP, IDX, S>>
where Array<T, CAP, S>: Archive, <Array<T, CAP, S> as Archive>::Archived: Deserialize<Array<T, CAP, S>, __D>, IDX: Archive, <IDX as Archive>::Archived: Deserialize<IDX, __D>,

Source§

fn deserialize( &self, deserializer: &mut __D, ) -> Result<Stack<T, CAP, IDX, S>, <__D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, u16, Bare>
where I: IntoIterator<Item = T>,

Source§

fn from(iterator: I) -> Stack<T, CAP, u16, Bare>

Returns a stack filled with an iterator, in the stack.

§Examples
let s: StackU8<_, 3> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, u16, Boxed>
where I: IntoIterator<Item = T>,

Available on crate feature alloc only.
Source§

fn from(iterator: I) -> Stack<T, CAP, u16, Boxed>

Returns a stack filled with an iterator, in the heap.

§Examples
let s: StackU8<_, 3, Boxed> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, u32, Bare>
where I: IntoIterator<Item = T>,

Source§

fn from(iterator: I) -> Stack<T, CAP, u32, Bare>

Returns a stack filled with an iterator, in the stack.

§Examples
let s: StackU8<_, 3> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, u32, Boxed>
where I: IntoIterator<Item = T>,

Available on crate feature alloc only.
Source§

fn from(iterator: I) -> Stack<T, CAP, u32, Boxed>

Returns a stack filled with an iterator, in the heap.

§Examples
let s: StackU8<_, 3, Boxed> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, u8, Bare>
where I: IntoIterator<Item = T>,

Source§

fn from(iterator: I) -> Stack<T, CAP, u8, Bare>

Returns a stack filled with an iterator, in the stack.

§Examples
let s: StackU8<_, 3> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, u8, Boxed>
where I: IntoIterator<Item = T>,

Available on crate feature alloc only.
Source§

fn from(iterator: I) -> Stack<T, CAP, u8, Boxed>

Returns a stack filled with an iterator, in the heap.

§Examples
let s: StackU8<_, 3, Boxed> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, usize, Bare>
where I: IntoIterator<Item = T>,

Source§

fn from(iterator: I) -> Stack<T, CAP, usize, Bare>

Returns a stack filled with an iterator, in the stack.

§Examples
let s: StackU8<_, 3> = [1, 2, 3].into();
Source§

impl<T: Default, I, const CAP: usize> From<I> for Stack<T, CAP, usize, Boxed>
where I: IntoIterator<Item = T>,

Available on crate feature alloc only.
Source§

fn from(iterator: I) -> Stack<T, CAP, usize, Boxed>

Returns a stack filled with an iterator, in the heap.

§Examples
let s: StackU8<_, 3, Boxed> = [1, 2, 3].into();
Source§

impl<T: Ord, const CAP: usize, S: Storage> Ord for Stack<T, CAP, u16, S>
where S::Stored<[T; CAP]>: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: Ord, const CAP: usize, S: Storage> Ord for Stack<T, CAP, u32, S>
where S::Stored<[T; CAP]>: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: Ord, const CAP: usize, S: Storage> Ord for Stack<T, CAP, u8, S>
where S::Stored<[T; CAP]>: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: Ord, const CAP: usize, S: Storage> Ord for Stack<T, CAP, usize, S>
where S::Stored<[T; CAP]>: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, const CAP: usize, IDX: PartialEq, S: Storage> PartialEq for Stack<T, CAP, IDX, S>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd, const CAP: usize, S: Storage> PartialOrd for Stack<T, CAP, u16, S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialOrd, const CAP: usize, S: Storage> PartialOrd for Stack<T, CAP, u32, S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialOrd, const CAP: usize, S: Storage> PartialOrd for Stack<T, CAP, u8, S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialOrd, const CAP: usize, S: Storage> PartialOrd for Stack<T, CAP, usize, S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<__S: Fallible + ?Sized, T, const CAP: usize, IDX, S: Storage> Serialize<__S> for Stack<T, CAP, IDX, S>
where Array<T, CAP, S>: Serialize<__S>, IDX: Serialize<__S>,

Source§

fn serialize( &self, serializer: &mut __S, ) -> Result<<Self as Archive>::Resolver, <__S as Fallible>::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl<T: Copy, const CAP: usize, IDX: Copy, S: Storage> Copy for Stack<T, CAP, IDX, S>
where S::Stored<[T; CAP]>: Copy,

Source§

impl<T: Eq, const CAP: usize, IDX: Eq, S: Storage> Eq for Stack<T, CAP, IDX, S>
where S::Stored<[T; CAP]>: Eq,

Auto Trait Implementations§

§

impl<T, const CAP: usize, IDX, S> Freeze for Stack<T, CAP, IDX, S>
where IDX: Freeze, <S as Storage>::Stored<[T; CAP]>: Freeze,

§

impl<T, const CAP: usize, IDX, S> RefUnwindSafe for Stack<T, CAP, IDX, S>

§

impl<T, const CAP: usize, IDX, S> Send for Stack<T, CAP, IDX, S>
where IDX: Send, <S as Storage>::Stored<[T; CAP]>: Send,

§

impl<T, const CAP: usize, IDX, S> Sync for Stack<T, CAP, IDX, S>
where IDX: Sync, <S as Storage>::Stored<[T; CAP]>: Sync,

§

impl<T, const CAP: usize, IDX, S> Unpin for Stack<T, CAP, IDX, S>
where IDX: Unpin, <S as Storage>::Stored<[T; CAP]>: Unpin,

§

impl<T, const CAP: usize, IDX, S> UnwindSafe for Stack<T, CAP, IDX, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
§

impl<T> ArchiveUnsized for T
where T: Archive,

§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByteSized for T

Source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
Source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Source§

impl<T, R> Chain<R> for T
where T: ?Sized,

Source§

fn chain<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Chain a function which takes the parameter by value.
Source§

fn chain_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Chain a function which takes the parameter by shared reference.
Source§

fn chain_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Chain a function which takes the parameter by exclusive reference.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ExtAny for T
where T: Any + ?Sized,

Source§

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
Source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_layout only.
Returns some shared reference to the inner value if it is of type T. Read more
Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_layout only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Source§

impl<T> ExtMem for T
where T: ?Sized,

Source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Source§

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Source§

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Source§

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Source§

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Source§

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Source§

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T> Hook for T

Source§

fn hook_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Source§

fn hook_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Ungil for T
where T: Send,