Fixing clippy errors in util
This commit is contained in:
@@ -41,7 +41,7 @@ impl Stream for RlpStream {
|
||||
stream
|
||||
}
|
||||
|
||||
fn append<'a, E>(&'a mut self, object: &E) -> &'a mut RlpStream where E: Encodable {
|
||||
fn append<E>(&mut self, object: &E) -> &mut RlpStream where E: Encodable {
|
||||
// encode given value and add it at the end of the stream
|
||||
object.encode(&mut self.encoder);
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Stream for RlpStream {
|
||||
self
|
||||
}
|
||||
|
||||
fn append_list<'a>(&'a mut self, len: usize) -> &'a mut RlpStream {
|
||||
fn append_list(&mut self, len: usize) -> &mut RlpStream {
|
||||
match len {
|
||||
0 => {
|
||||
// we may finish, if the appended list len is equal 0
|
||||
@@ -69,7 +69,7 @@ impl Stream for RlpStream {
|
||||
self
|
||||
}
|
||||
|
||||
fn append_empty_data<'a>(&'a mut self) -> &'a mut RlpStream {
|
||||
fn append_empty_data(&mut self) -> &mut RlpStream {
|
||||
// self push raw item
|
||||
self.encoder.bytes.push(0x80);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ pub trait Decoder: Sized {
|
||||
where F: FnOnce(&[u8]) -> Result<T, DecoderError>;
|
||||
|
||||
fn as_list(&self) -> Result<Vec<Self>, DecoderError>;
|
||||
fn as_rlp<'a>(&'a self) -> &'a UntrustedRlp<'a>;
|
||||
fn as_rlp(&self) -> &UntrustedRlp;
|
||||
fn as_raw(&self) -> &[u8];
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ pub trait Stream: Sized {
|
||||
/// assert_eq!(out, vec![0xca, 0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g', 0x80]);
|
||||
/// }
|
||||
/// ```
|
||||
fn append_list<'a>(&'a mut self, len: usize) -> &'a mut Self;
|
||||
fn append_list(&mut self, len: usize) -> &mut Self;
|
||||
|
||||
/// Apends null to the end of stream, chainable.
|
||||
///
|
||||
@@ -246,7 +246,7 @@ pub trait Stream: Sized {
|
||||
/// assert_eq!(out, vec![0xc2, 0x80, 0x80]);
|
||||
/// }
|
||||
/// ```
|
||||
fn append_empty_data<'a>(&'a mut self) -> &'a mut Self;
|
||||
fn append_empty_data(&mut self) -> &mut Self;
|
||||
|
||||
/// Appends raw (pre-serialised) RLP data. Use with caution. Chainable.
|
||||
fn append_raw<'a>(&'a mut self, bytes: &[u8], item_count: usize) -> &'a mut Self;
|
||||
|
||||
@@ -282,7 +282,7 @@ impl<'a> BasicDecoder<'a> {
|
||||
|
||||
/// Return first item info
|
||||
fn payload_info(bytes: &[u8]) -> Result<PayloadInfo, DecoderError> {
|
||||
let item = match bytes.first().map(|&x| x) {
|
||||
let item = match bytes.first().cloned() {
|
||||
None => return Err(DecoderError::RlpIsTooShort),
|
||||
Some(0...0x7f) => PayloadInfo::new(0, 1),
|
||||
Some(l @ 0x80...0xb7) => PayloadInfo::new(1, l as usize - 0x80),
|
||||
@@ -318,7 +318,7 @@ impl<'a> Decoder for BasicDecoder<'a> {
|
||||
|
||||
let bytes = self.rlp.as_raw();
|
||||
|
||||
match bytes.first().map(|&x| x) {
|
||||
match bytes.first().cloned() {
|
||||
// rlp is too short
|
||||
None => Err(DecoderError::RlpIsTooShort),
|
||||
// single byt value
|
||||
@@ -349,12 +349,12 @@ impl<'a> Decoder for BasicDecoder<'a> {
|
||||
|
||||
fn as_list(&self) -> Result<Vec<Self>, DecoderError> {
|
||||
let v: Vec<BasicDecoder<'a>> = self.rlp.iter()
|
||||
.map(| i | BasicDecoder::new(i))
|
||||
.map(BasicDecoder::new)
|
||||
.collect();
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
fn as_rlp<'s>(&'s self) -> &'s UntrustedRlp<'s> {
|
||||
fn as_rlp(&self) -> &UntrustedRlp {
|
||||
&self.rlp
|
||||
}
|
||||
}
|
||||
@@ -399,6 +399,7 @@ impl<T> Decodable for Option<T> where T: Decodable {
|
||||
macro_rules! impl_array_decodable {
|
||||
($index_type:ty, $len:expr ) => (
|
||||
impl<T> Decodable for [T; $len] where T: Decodable {
|
||||
#[allow(len_zero)]
|
||||
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
|
||||
let decoders = try!(decoder.as_list());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user