Macro cl_structures::stack::stack

source ·
pub macro stack {
    ($count:literal) => { ... },
    ($value:expr ; $count:literal) => { ... },
    ($($values:expr),* $(,)?) => { ... },
}
Expand description

Creates a stack containing the arguments

§Examples

Creates a full Stack containing a list of elements

let mut v = stack![1, 2, 3];

assert_eq!(Some(3), v.pop());
assert_eq!(Some(2), v.pop());
assert_eq!(Some(1), v.pop());
assert_eq!(None, v.pop());

Creates a full Stack from a given element and size

let mut v = stack![1; 2];

assert_eq!(Some(1), v.pop());
assert_eq!(Some(1), v.pop());
assert_eq!(None, v.pop());

Creates an empty Stack from a given size

let mut v = stack![10];

assert_eq!(0, v.len());
assert_eq!(10, v.capacity());

v.push(10);
assert_eq!(Some(&10), v.last());