Skip to content

Commit ceaf0ac

Browse files
committed
Fixup Rust 1.52 cargo clippy suggestions
1 parent a9cdc3a commit ceaf0ac

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

src/de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ where
6666
/// An error is returned if there are unconsumed bytes in the readable source.
6767
pub fn end(&mut self) -> Result<()> {
6868
match self.read.peek() {
69-
Some(r) => r.and_then(|_| Err(Error::TrailingData)),
69+
Some(r) => r.and(Err(Error::TrailingData)),
7070
None => Ok(()),
7171
}
7272
}

src/ser.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,7 @@ where
372372
where
373373
T: ?Sized + Serialize,
374374
{
375-
let key = self
376-
.current_key
377-
.take()
378-
.ok_or_else(|| Error::ValueWithoutKey)?;
375+
let key = self.current_key.take().ok_or(Error::ValueWithoutKey)?;
379376
let buf: Vec<u8> = Vec::new();
380377
let mut ser = Serializer::new(buf);
381378
value.serialize(&mut ser)?;

src/value.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,14 @@ impl Value {
138138

139139
pub fn as_u64(&self) -> Option<u64> {
140140
match self {
141-
Value::Int(n) => match n {
142-
Number::Unsigned(n) => Some(*n),
143-
_ => None,
144-
},
141+
Value::Int(Number::Unsigned(n)) => Some(*n),
145142
_ => None,
146143
}
147144
}
148145

149146
pub fn as_i64(&self) -> Option<i64> {
150147
match self {
151-
Value::Int(n) => match n {
152-
Number::Signed(n) => Some(*n),
153-
_ => None,
154-
},
148+
Value::Int(Number::Signed(n)) => Some(*n),
155149
_ => None,
156150
}
157151
}

src/value/ser.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,7 @@ impl ser::SerializeMap for SerializeDict {
276276
where
277277
T: ?Sized + Serialize,
278278
{
279-
let key = self
280-
.current_key
281-
.take()
282-
.ok_or_else(|| Error::ValueWithoutKey)?;
279+
let key = self.current_key.take().ok_or(Error::ValueWithoutKey)?;
283280
let value = to_value(value)?;
284281
self.dict.insert(key, value);
285282
Ok(())

0 commit comments

Comments
 (0)