From 90de29e6cbbcd015c1315137be4fd2d4d4ce1874 Mon Sep 17 00:00:00 2001 From: bluss Date: Fri, 18 Sep 2015 00:53:19 +0200 Subject: [PATCH] Remove zero from the Index trait --- src/array.rs | 5 ----- src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/array.rs b/src/array.rs index aa3b7ae..e5ce1cc 100644 --- a/src/array.rs +++ b/src/array.rs @@ -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)] diff --git a/src/lib.rs b/src/lib.rs index 73d9324..de84109 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,7 +96,7 @@ impl ArrayVec { /// ``` pub fn new() -> ArrayVec { 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 IntoIterator for ArrayVec { type Item = A::Item; type IntoIter = IntoIter; fn into_iter(self) -> IntoIter { - IntoIter { index: Index::zero(), v: self, } + IntoIter { index: Index::from(0), v: self, } } }