1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
///trait to impl for any type that represents a collection of items
pub trait Collection 
{
    ///Item Type of collection
    type Item;
    ///Number of items in the collection
    fn size(&self) -> usize;
    ///Helper function for whether collection has elements
    fn is_empty(&self) -> bool{self.size() == 0}
}

///trait for collections that can be mutated. Inherits from Collection trait
pub trait MutableCollection: Collection 
{
	///adds an item to the end of a collection
	fn push(&mut self, item: Self::Item) -> (); 
	///removes an item from the end of a collection
	fn pop(&mut self) -> Option<Self::Item>;
	///inserts at a specific index
	fn insert_at(&mut self, index: usize, item: Self::Item) -> ();
	///removes item at a specific index
	fn remove_at(&mut self, index:usize) -> Option<Self::Item>;
}

///trait that converts type to mutable array. Required for default shuffle implementation
pub trait Sliceable{
	type Item;
	fn as_mut_slice(&mut self) -> &mut [Self::Item];
}