Remove zero from the Index trait
This commit is contained in:
@@ -15,14 +15,11 @@ pub unsafe trait Array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait Index : PartialEq + Copy {
|
pub trait Index : PartialEq + Copy {
|
||||||
fn zero() -> Self;
|
|
||||||
fn to_usize(self) -> usize;
|
fn to_usize(self) -> usize;
|
||||||
fn from(usize) -> Self;
|
fn from(usize) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Index for u8 {
|
impl Index for u8 {
|
||||||
#[inline(always)]
|
|
||||||
fn zero() -> Self { 0 }
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_usize(self) -> usize { self as usize }
|
fn to_usize(self) -> usize { self as usize }
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@@ -30,8 +27,6 @@ impl Index for u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Index for u16 {
|
impl Index for u16 {
|
||||||
#[inline(always)]
|
|
||||||
fn zero() -> Self { 0 }
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_usize(self) -> usize { self as usize }
|
fn to_usize(self) -> usize { self as usize }
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|||||||
+2
-2
@@ -96,7 +96,7 @@ impl<A: Array> ArrayVec<A> {
|
|||||||
/// ```
|
/// ```
|
||||||
pub fn new() -> ArrayVec<A> {
|
pub fn new() -> ArrayVec<A> {
|
||||||
unsafe {
|
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 Item = A::Item;
|
||||||
type IntoIter = IntoIter<A>;
|
type IntoIter = IntoIter<A>;
|
||||||
fn into_iter(self) -> IntoIter<A> {
|
fn into_iter(self) -> IntoIter<A> {
|
||||||
IntoIter { index: Index::zero(), v: self, }
|
IntoIter { index: Index::from(0), v: self, }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user