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
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
use crate::{
	Collection,
	WithCapacity,
	Len,
	Capacity,
	Reserve,
	Back,
	BackMut,
	Front,
	FrontMut,
	PushBack,
	PopBack,
	Remove,
	Clear
};

impl<T> Collection for Vec<T> {
	type Item = T;
}

impl<T> WithCapacity for Vec<T> {
	#[inline(always)]
	fn with_capacity(capacity: usize) -> Self {
		Vec::with_capacity(capacity)
	}
}

impl<T> Len for Vec<T> {
	#[inline(always)]
	fn len(&self) -> usize {
		self.len()
	}

	#[inline(always)]
	fn is_empty(&self) -> bool {
		self.is_empty()
	}
}

impl<T> Capacity for Vec<T> {
	fn capacity(&self) -> usize {
		self.capacity()
	}
}

impl<T> Reserve for Vec<T> {
	fn reserve(&mut self, additional: usize) {
		self.reserve(additional)
	}
}

impl<T> Back for Vec<T> {
	fn back(&self) -> Option<&T> {
		self.last()
	}
}

impl<T> BackMut for Vec<T> {
	fn back_mut(&mut self) -> Option<&mut T> {
		self.last_mut()
	}
}

impl<T> Front for Vec<T> {
	fn front(&self) -> Option<&T> {
		self.first()
	}
}

impl<T> FrontMut for Vec<T> {
	fn front_mut(&mut self) -> Option<&mut T> {
		self.first_mut()
	}
}

impl<T> PushBack for Vec<T> {
	type Output = ();

	fn push_back(&mut self, t: T) {
		self.push(t)
	}
}

impl<T> PopBack for Vec<T> {
	fn pop_back(&mut self) -> Option<T> {
		self.pop()
	}
}

impl<T> Remove<usize> for Vec<T> {
	fn remove(&mut self, index: usize) -> Option<T> {
		if index < self.len() {
			Some(self.remove(index))
		} else {
			None
		}
	}
}

impl<T> Clear for Vec<T> {
	fn clear(&mut self) {
		self.clear()
	}
}