aboutsummaryrefslogtreecommitdiff
path: root/primrose/src/traits/mod.rs
blob: 5d986395027562baa58109c42213146921835426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pub mod container_constructor;

pub trait Container<T> {
    fn len(&mut self) -> usize;
    fn contains(&mut self, x: &T) -> bool;
    fn is_empty(&mut self) -> bool;
    fn insert(&mut self, elt: T);
    fn clear(&mut self);
    fn remove(&mut self, elt: T) -> Option<T>; // remove first occurance
}

pub trait Stack<T> {
    fn push(&mut self, elt: T);
    fn pop(&mut self) -> Option<T>;
}

pub trait Indexable<T> {
    fn first(&mut self) -> Option<&T>;
    fn last(&mut self) -> Option<&T>;
    fn nth(&mut self, n: usize) -> Option<&T>;
}