From 7af05a9ba7460788f44de82de61e9cf5992467c6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 1 Sep 2022 22:31:34 -0700 Subject: [PATCH] Resolve needless_borrow clippy lints error: the borrowed expression implements the required traits --> src/value/ser.rs:198:60 | 198 | values.insert(String::from(variant), tri!(to_value(&value))); | ^^^^^^ help: change this to: `value` | = note: `-D clippy::needless-borrow` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> src/value/ser.rs:317:37 | 317 | self.vec.push(tri!(to_value(&value))); | ^^^^^^ help: change this to: `value` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> src/value/ser.rs:366:37 | 366 | self.vec.push(tri!(to_value(&value))); | ^^^^^^ help: change this to: `value` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> src/value/ser.rs:409:47 | 409 | map.insert(key, tri!(to_value(&value))); | ^^^^^^ help: change this to: `value` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> src/value/ser.rs:666:58 | 666 | self.map.insert(String::from(key), tri!(to_value(&value))); | ^^^^^^ help: change this to: `value` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/test.rs:98:26 | 98 | let v = to_value(&value).unwrap(); | ^^^^^^ help: change this to: `value` | = note: `-D clippy::needless-borrow` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow error: the borrowed expression implements the required traits --> tests/test.rs:114:26 | 114 | let v = to_value(&value).unwrap(); | ^^^^^^ help: change this to: `value` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow --- src/value/ser.rs | 10 +++++----- tests/test.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/value/ser.rs b/src/value/ser.rs index c142dacbf..37e495f65 100644 --- a/src/value/ser.rs +++ b/src/value/ser.rs @@ -195,7 +195,7 @@ impl serde::Serializer for Serializer { T: ?Sized + Serialize, { let mut values = Map::new(); - values.insert(String::from(variant), tri!(to_value(&value))); + values.insert(String::from(variant), tri!(to_value(value))); Ok(Value::Object(values)) } @@ -314,7 +314,7 @@ impl serde::ser::SerializeSeq for SerializeVec { where T: ?Sized + Serialize, { - self.vec.push(tri!(to_value(&value))); + self.vec.push(tri!(to_value(value))); Ok(()) } @@ -363,7 +363,7 @@ impl serde::ser::SerializeTupleVariant for SerializeTupleVariant { where T: ?Sized + Serialize, { - self.vec.push(tri!(to_value(&value))); + self.vec.push(tri!(to_value(value))); Ok(()) } @@ -406,7 +406,7 @@ impl serde::ser::SerializeMap for SerializeMap { // Panic because this indicates a bug in the program rather than an // expected failure. let key = key.expect("serialize_value called before serialize_key"); - map.insert(key, tri!(to_value(&value))); + map.insert(key, tri!(to_value(value))); Ok(()) } #[cfg(feature = "arbitrary_precision")] @@ -663,7 +663,7 @@ impl serde::ser::SerializeStructVariant for SerializeStructVariant { where T: ?Sized + Serialize, { - self.map.insert(String::from(key), tri!(to_value(&value))); + self.map.insert(String::from(key), tri!(to_value(value))); Ok(()) } diff --git a/tests/test.rs b/tests/test.rs index 0aeaff88d..396d55bc4 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -95,7 +95,7 @@ where let s = to_string(value).unwrap(); assert_eq!(s, out); - let v = to_value(&value).unwrap(); + let v = to_value(value).unwrap(); let s = to_string(&v).unwrap(); assert_eq!(s, out); } @@ -111,7 +111,7 @@ where let s = to_string_pretty(value).unwrap(); assert_eq!(s, out); - let v = to_value(&value).unwrap(); + let v = to_value(value).unwrap(); let s = to_string_pretty(&v).unwrap(); assert_eq!(s, out); }