Struct coco::stack::Stack
[−]
[src]
pub struct Stack<T> { /* fields omitted */ }
A lock-free stack.
It can be used with multiple producers and multiple consumers at the same time.
Methods
impl<T> Stack<T>
[src]
fn new() -> Self
fn is_empty(&self) -> bool
Returns true
if the stack is empty.
Examples
use coco::Stack; let s = Stack::new(); assert!(s.is_empty()); s.push("hello"); assert!(!s.is_empty());
fn push(&self, value: T)
Pushes a new value onto the stack.
Examples
use coco::Stack; let s = Stack::new(); s.push(1); s.push(2);
fn pop(&self) -> Option<T>
Attemps to pop an value from the stack.
Returns None
if the stack is empty.
Examples
use coco::Stack; let s = Stack::new(); s.push(1); s.push(2); assert_eq!(s.pop(), Some(2)); assert_eq!(s.pop(), Some(1)); assert_eq!(s.pop(), None);