Remove zero from the Index trait

This commit is contained in:
bluss
2015-09-18 00:53:19 +02:00
parent 6af588cb2c
commit 90de29e6cb
2 changed files with 2 additions and 7 deletions
-5
View File
@@ -15,14 +15,11 @@ pub unsafe trait Array {
}
pub trait Index : PartialEq + Copy {
fn zero() -> Self;
fn to_usize(self) -> usize;
fn from(usize) -> Self;
}
impl Index for u8 {
#[inline(always)]
fn zero() -> Self { 0 }
#[inline(always)]
fn to_usize(self) -> usize { self as usize }
#[inline(always)]
@@ -30,8 +27,6 @@ impl Index for u8 {
}
impl Index for u16 {
#[inline(always)]
fn zero() -> Self { 0 }
#[inline(always)]
fn to_usize(self) -> usize { self as usize }
#[inline(always)]
+2 -2
View File
@@ -96,7 +96,7 @@ impl<A: Array> ArrayVec<A> {
/// ```
pub fn new() -> ArrayVec<A> {
unsafe {
ArrayVec { xs: NoDrop::new(new_array()), len: Index::zero() }
ArrayVec { xs: NoDrop::new(new_array()), len: Index::from(0) }
}
}
@@ -440,7 +440,7 @@ impl<A: Array> IntoIterator for ArrayVec<A> {
type Item = A::Item;
type IntoIter = IntoIter<A>;
fn into_iter(self) -> IntoIter<A> {
IntoIter { index: Index::zero(), v: self, }
IntoIter { index: Index::from(0), v: self, }
}
}