Skip to content

Commit

Permalink
minor: fix clippy (crossterm-rs#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelatkinson authored Jun 22, 2021
1 parent a2d40b8 commit fa22f4e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/bson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Display for Bson {
}) => write!(fmt, "/{}/{}", pattern, options),
Bson::JavaScriptCode(ref code)
| Bson::JavaScriptCodeWithScope(JavaScriptCodeWithScope { ref code, .. }) => {
fmt.write_str(&code)
fmt.write_str(code)
}
Bson::Int32(i) => write!(fmt, "{}", i),
Bson::Int64(i) => write!(fmt, "{}", i),
Expand Down
2 changes: 1 addition & 1 deletion src/de/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'de> de::Deserializer<'de> for Deserializer {
Bson::Binary(Binary {
subtype: BinarySubtype::Generic,
ref bytes,
}) => visitor.visit_bytes(&bytes),
}) => visitor.visit_bytes(bytes),
binary @ Bson::Binary(..) => visitor.visit_map(MapDeserializer {
iter: binary.to_extended_document().into_iter(),
value: None,
Expand Down
2 changes: 1 addition & 1 deletion src/extjson/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl TryFrom<serde_json::Value> for Bson {
.or_else(|| x.as_f64().map(Bson::from))
.ok_or_else(|| {
Error::invalid_value(
Unexpected::Other(&format!("{}", x).as_str()),
Unexpected::Other(format!("{}", x).as_str()),
&"a number that could fit in i32, i64, or f64",
)
}),
Expand Down
8 changes: 4 additions & 4 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ pub(crate) fn serialize_bson<W: Write + ?Sized>(

match *val {
Bson::Double(v) => write_f64(writer, v),
Bson::String(ref v) => write_string(writer, &v),
Bson::Array(ref v) => serialize_array(writer, &v),
Bson::String(ref v) => write_string(writer, v),
Bson::Array(ref v) => serialize_array(writer, v),
Bson::Document(ref v) => v.to_writer(writer),
Bson::Boolean(v) => writer
.write_all(&[if v { 0x01 } else { 0x00 }])
Expand All @@ -121,7 +121,7 @@ pub(crate) fn serialize_bson<W: Write + ?Sized>(
write_cstring(writer, pattern)?;
write_cstring(writer, options)
}
Bson::JavaScriptCode(ref code) => write_string(writer, &code),
Bson::JavaScriptCode(ref code) => write_string(writer, code),
Bson::ObjectId(ref id) => writer.write_all(&id.bytes()).map_err(From::from),
Bson::JavaScriptCodeWithScope(JavaScriptCodeWithScope {
ref code,
Expand Down Expand Up @@ -155,7 +155,7 @@ pub(crate) fn serialize_bson<W: Write + ?Sized>(
}
Bson::DateTime(ref v) => write_i64(writer, v.timestamp_millis()),
Bson::Null => Ok(()),
Bson::Symbol(ref v) => write_string(writer, &v),
Bson::Symbol(ref v) => write_string(writer, v),
#[cfg(not(feature = "decimal128"))]
Bson::Decimal128(ref v) => {
writer.write_all(&v.bytes)?;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/modules/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ fn test_getters() {

doc.insert("null".to_string(), Bson::Null);
assert_eq!(Some(&Bson::Null), doc.get("null"));
assert_eq!(true, doc.is_null("null"));
assert_eq!(false, doc.is_null("array"));
assert!(doc.is_null("null"));
assert!(!doc.is_null("array"));

assert_eq!(Some(&Bson::Int32(1)), doc.get("i32"));
assert_eq!(Ok(1i32), doc.get_i32("i32"));
Expand Down
2 changes: 1 addition & 1 deletion src/tests/modules/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn boolean() {
let _guard = LOCK.run_concurrently();
let obj = Bson::Boolean(true);
let b: bool = from_bson(obj.clone()).unwrap();
assert_eq!(b, true);
assert!(b);

let deser: Bson = to_bson(&b).unwrap();
assert_eq!(deser, obj);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ fn test_datetime_helpers() {
}
}
}"#;
let json: serde_json::Value = serde_json::from_str(&date).unwrap();
let json: serde_json::Value = serde_json::from_str(date).unwrap();
let b: B = serde_json::from_value(json).unwrap();
let expected: chrono::DateTime<chrono::Utc> =
chrono::DateTime::from_str("2020-06-09 10:58:07.095 UTC").unwrap();
Expand Down

0 comments on commit fa22f4e

Please sign in to comment.