Simplify Index implementations

This commit is contained in:
Andrew Poelstra 2015-04-05 12:16:56 -05:00
parent c3786888d7
commit 5b3858e0ce
2 changed files with 12 additions and 12 deletions

View File

@ -404,8 +404,8 @@ impl ops::Index<ops::Range<usize>> for PublicKeyData {
#[inline]
fn index(&self, index: ops::Range<usize>) -> &[u8] {
match *self {
PublicKeyData::Compressed(ref x) => &x[index.start..index.end],
PublicKeyData::Uncompressed(ref x) => &x[index.start..index.end]
PublicKeyData::Compressed(ref x) => &x[index],
PublicKeyData::Uncompressed(ref x) => &x[index]
}
}
}
@ -416,7 +416,7 @@ impl ops::Index<ops::Range<usize>> for PublicKey {
#[inline]
fn index(&self, index: ops::Range<usize>) -> &[u8] {
let &PublicKey(ref dat) = self;
&dat[index.start..index.end]
&dat[index]
}
}
@ -426,8 +426,8 @@ impl ops::Index<ops::RangeTo<usize>> for PublicKeyData {
#[inline]
fn index(&self, index: ops::RangeTo<usize>) -> &[u8] {
match *self {
PublicKeyData::Compressed(ref x) => &x[..index.end],
PublicKeyData::Uncompressed(ref x) => &x[..index.end]
PublicKeyData::Compressed(ref x) => &x[index],
PublicKeyData::Uncompressed(ref x) => &x[index]
}
}
}
@ -438,7 +438,7 @@ impl ops::Index<ops::RangeTo<usize>> for PublicKey {
#[inline]
fn index(&self, index: ops::RangeTo<usize>) -> &[u8] {
let &PublicKey(ref dat) = self;
&dat[..index.end]
&dat[index]
}
}
@ -448,8 +448,8 @@ impl ops::Index<ops::RangeFrom<usize>> for PublicKeyData {
#[inline]
fn index(&self, index: ops::RangeFrom<usize>) -> &[u8] {
match *self {
PublicKeyData::Compressed(ref x) => &x[index.start..],
PublicKeyData::Uncompressed(ref x) => &x[index.start..]
PublicKeyData::Compressed(ref x) => &x[index],
PublicKeyData::Uncompressed(ref x) => &x[index]
}
}
}
@ -460,7 +460,7 @@ impl ops::Index<ops::RangeFrom<usize>> for PublicKey {
#[inline]
fn index(&self, index: ops::RangeFrom<usize>) -> &[u8] {
let &PublicKey(ref dat) = self;
&dat[index.start..]
&dat[index]
}
}

View File

@ -78,7 +78,7 @@ macro_rules! impl_array_newtype {
#[inline]
fn index(&self, index: ::std::ops::Range<usize>) -> &[$ty] {
let &$thing(ref dat) = self;
&dat[index.start..index.end]
&dat[index]
}
}
@ -88,7 +88,7 @@ macro_rules! impl_array_newtype {
#[inline]
fn index(&self, index: ::std::ops::RangeTo<usize>) -> &[$ty] {
let &$thing(ref dat) = self;
&dat[..index.end]
&dat[index]
}
}
@ -98,7 +98,7 @@ macro_rules! impl_array_newtype {
#[inline]
fn index(&self, index: ::std::ops::RangeFrom<usize>) -> &[$ty] {
let &$thing(ref dat) = self;
&dat[index.start..]
&dat[index]
}
}