Type Alias StackU8

Source
pub type StackU8<T, const CAP: usize, S = Bare> = Stack<T, CAP, u8, S>;
Available on crate feature _stack_u8 only.
Expand description

📦 A Stack with an 8-bit index size.

Aliased Type§

struct StackU8<T, const CAP: usize, S = Bare> { /* private fields */ }

Implementations

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> ⓘ

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§

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>, ()>

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§

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>, ()>

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>, ()>

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: 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> ⓘ

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>

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, 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: 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, 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>

§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, 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 feature alloc 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§

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 feature alloc 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 feature alloc 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: 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, 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, 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: 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: 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, u8, Bare>

§Methods for StackU8



This impl block contains no items.

Trait Implementations

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, 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 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: 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<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: 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: 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, 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: 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,