diff options
| -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 | ||||
| -rw-r--r-- | tests/serde_tests/mod.rs | 9 | 
6 files changed, 33 insertions, 35 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)), diff --git a/tests/serde_tests/mod.rs b/tests/serde_tests/mod.rs index 2b3ab85..3b1f76b 100644 --- a/tests/serde_tests/mod.rs +++ b/tests/serde_tests/mod.rs @@ -32,7 +32,7 @@ fn new_serializer() -> Serializer<VecWriter> {  }  fn new_deserializer(events: Vec<PlistEvent>) -> Deserializer<Vec<PlistResult<PlistEvent>>> { -    let result_events = events.into_iter().map(|e| Ok(e)).collect(); +    let result_events = events.into_iter().map(Ok).collect();      Deserializer::new(result_events)  } @@ -45,11 +45,8 @@ fn assert_roundtrip<T>(obj: T, comparison: Option<&[PlistEvent]>)      let events = se.into_inner().into_inner(); -    match comparison { -        Some(comparison) => { -            assert_eq!(&events[..], comparison); -        } -        None => (), +    if let Some(comparison) = comparison { +        assert_eq!(&events[..], comparison);      }      let mut de = new_deserializer(events); | 
