diff options
| author | Edward Barnard | 2017-06-07 13:02:19 +0100 |
|---|---|---|
| committer | Edward Barnard | 2017-06-07 13:02:19 +0100 |
| commit | b0d6118889409aa6fb13a7855d5ede17c3d11cc1 (patch) | |
| tree | 0ea95cbbc0db52c98549642b3da1a9f82895ec69 /src | |
| parent | 1bbe75304c630ce585fa2da3dfdff2482c21c78f (diff) | |
| download | rust-plist-b0d6118889409aa6fb13a7855d5ede17c3d11cc1.tar.bz2 | |
Address some clippy warnings.
Diffstat (limited to 'src')
| -rw-r--r-- | src/date.rs | 2 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/plist.rs | 44 | ||||
| -rw-r--r-- | src/serde/de.rs | 4 | ||||
| -rw-r--r-- | src/xml/reader.rs | 7 |
5 files changed, 30 insertions, 29 deletions
diff --git a/src/date.rs b/src/date.rs index 01c5c9d..55aa205 100644 --- a/src/date.rs +++ b/src/date.rs @@ -61,7 +61,7 @@ impl FromStr for Date { type Err = (); fn from_str(s: &str) -> ::std::result::Result<Self, Self::Err> { - let date = DateTime::parse_from_rfc3339(&s).map_err(|_| ())?; + let date = DateTime::parse_from_rfc3339(s).map_err(|_| ())?; Ok(Date { inner: date.with_timezone(&UTC) }) } } @@ -169,7 +169,7 @@ impl<R: Read + Seek> EventReader<R> { reader.read_exact(&mut magic)?; reader.seek(SeekFrom::Start(0))?; - Ok(if &magic == b"bplist00" { true } else { false }) + Ok(&magic == b"bplist00") } } diff --git a/src/plist.rs b/src/plist.rs index 14a16ce..7930754 100644 --- a/src/plist.rs +++ b/src/plist.rs @@ -39,14 +39,14 @@ impl Plist { match self { Plist::Array(array) => { events.push(PlistEvent::StartArray(Some(array.len() as u64))); - for value in array.into_iter() { + for value in array { value.into_events_inner(events); } events.push(PlistEvent::EndArray); } Plist::Dictionary(dict) => { events.push(PlistEvent::StartDictionary(Some(dict.len() as u64))); - for (key, value) in dict.into_iter() { + for (key, value) in dict { events.push(PlistEvent::StringValue(key)); value.into_events_inner(events); } @@ -64,8 +64,8 @@ impl Plist { /// If the `Plist` is an Array, returns the associated Vec. /// Returns None otherwise. pub fn as_array(&self) -> Option<&Vec<Plist>> { - match self { - &Plist::Array(ref array) => Some(array), + match *self { + Plist::Array(ref array) => Some(array), _ => None, } } @@ -73,8 +73,8 @@ impl Plist { /// If the `Plist` is an Array, returns the associated mutable Vec. /// Returns None otherwise. pub fn as_array_mut(&mut self) -> Option<&mut Vec<Plist>> { - match self { - &mut Plist::Array(ref mut array) => Some(array), + match *self { + Plist::Array(ref mut array) => Some(array), _ => None, } } @@ -82,8 +82,8 @@ impl Plist { /// If the `Plist` is a Dictionary, returns the associated BTreeMap. /// Returns None otherwise. pub fn as_dictionary(&self) -> Option<&BTreeMap<String, Plist>> { - match self { - &Plist::Dictionary(ref map) => Some(map), + match *self { + Plist::Dictionary(ref map) => Some(map), _ => None, } } @@ -91,8 +91,8 @@ impl Plist { /// If the `Plist` is a Dictionary, returns the associated mutable BTreeMap. /// Returns None otherwise. pub fn as_dictionary_mut(&mut self) -> Option<&mut BTreeMap<String, Plist>> { - match self { - &mut Plist::Dictionary(ref mut map) => Some(map), + match *self { + Plist::Dictionary(ref mut map) => Some(map), _ => None, } } @@ -100,8 +100,8 @@ impl Plist { /// If the `Plist` is a Boolean, returns the associated bool. /// Returns None otherwise. pub fn as_boolean(&self) -> Option<bool> { - match self { - &Plist::Boolean(v) => Some(v), + match *self { + Plist::Boolean(v) => Some(v), _ => None, } } @@ -121,8 +121,8 @@ impl Plist { /// If the `Plist` is a Data, returns the associated Vec. /// Returns None otherwise. pub fn as_data(&self) -> Option<&[u8]> { - match self { - &Plist::Data(ref data) => Some(data), + match *self { + Plist::Data(ref data) => Some(data), _ => None, } } @@ -130,8 +130,8 @@ impl Plist { /// If the `Plist` is a Date, returns the associated DateTime. /// Returns None otherwise. pub fn as_date(&self) -> Option<&Date> { - match self { - &Plist::Date(ref date) => Some(date), + match *self { + Plist::Date(ref date) => Some(date), _ => None, } } @@ -139,8 +139,8 @@ impl Plist { /// If the `Plist` is a Real, returns the associated f64. /// Returns None otherwise. pub fn as_real(&self) -> Option<f64> { - match self { - &Plist::Real(v) => Some(v), + match *self { + Plist::Real(v) => Some(v), _ => None, } } @@ -148,8 +148,8 @@ impl Plist { /// If the `Plist` is an Integer, returns the associated i64. /// Returns None otherwise. pub fn as_integer(&self) -> Option<i64> { - match self { - &Plist::Integer(v) => Some(v), + match *self { + Plist::Integer(v) => Some(v), _ => None, } } @@ -169,8 +169,8 @@ impl Plist { /// If the `Plist` is a String, returns the associated str. /// Returns None otherwise. pub fn as_string(&self) -> Option<&str> { - match self { - &Plist::String(ref v) => Some(v), + match *self { + Plist::String(ref v) => Some(v), _ => None, } } diff --git a/src/serde/de.rs b/src/serde/de.rs index aeca9ec..87ccc64 100644 --- a/src/serde/de.rs +++ b/src/serde/de.rs @@ -70,7 +70,7 @@ impl<'de, 'a, I> de::Deserializer<'de> for &'a mut Deserializer<I> expect!(self.events.next(), PlistEvent::EndArray); Ok(ret) } - PlistEvent::EndArray => return Err(event_mismatch_error()), + PlistEvent::EndArray => Err(event_mismatch_error()), PlistEvent::StartDictionary(len) => { let len = u64_option_to_usize(len)?; @@ -78,7 +78,7 @@ impl<'de, 'a, I> de::Deserializer<'de> for &'a mut Deserializer<I> expect!(self.events.next(), PlistEvent::EndDictionary); Ok(ret) } - PlistEvent::EndDictionary => return Err(event_mismatch_error()), + PlistEvent::EndDictionary => Err(event_mismatch_error()), PlistEvent::BooleanValue(v) => visitor.visit_bool(v), PlistEvent::DataValue(v) => visitor.visit_byte_buf(v), diff --git a/src/xml/reader.rs b/src/xml/reader.rs index e536033..465d264 100644 --- a/src/xml/reader.rs +++ b/src/xml/reader.rs @@ -109,9 +109,10 @@ impl<R: Read> EventReader<R> { } } Ok(XmlEvent::EndDocument) => { - match self.element_stack.is_empty() { - true => return None, - false => return Some(Err(Error::UnexpectedEof)), + if self.element_stack.is_empty() { + return None; + } else { + return Some(Err(Error::UnexpectedEof)); } } Err(_) => return Some(Err(Error::InvalidData)), |
