Skip to content

Commit da8799c

Browse files
committed
minor: fix clippy
1 parent fac57aa commit da8799c

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

examples/serialize.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
use std::io::Cursor;
22

3-
use bson::{oid, Array, Bson, Document};
3+
use bson::{oid, Bson, Document};
44

55
fn main() {
66
let mut doc = Document::new();
77
doc.insert("foo".to_string(), Bson::String("bar".to_string()));
88

9-
let mut arr = Array::new();
10-
arr.push(Bson::String("blah".to_string()));
11-
arr.push(Bson::DateTime(chrono::Utc::now()));
12-
arr.push(Bson::ObjectId(oid::ObjectId::with_bytes([
13-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
14-
])));
9+
let arr = vec![
10+
Bson::String("blah".to_string()),
11+
Bson::DateTime(chrono::Utc::now()),
12+
Bson::ObjectId(oid::ObjectId::with_bytes([
13+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
14+
])),
15+
];
1516

1617
doc.insert("array".to_string(), Bson::Array(arr));
1718

serde-tests/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(clippy::cognitive_complexity)]
2+
#![allow(clippy::vec_init_then_push)]
23

34
use serde::{self, de::Unexpected, Deserialize, Serialize};
45
use std::collections::{BTreeMap, HashSet};

src/decimal128.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ impl std::str::FromStr for Decimal128 {
239239
}
240240

241241
#[cfg(feature = "decimal128")]
242-
impl Into<d128> for Decimal128 {
243-
fn into(self) -> d128 {
244-
self.inner
242+
impl From<Decimal128> for d128 {
243+
fn from(decimal: Decimal128) -> d128 {
244+
decimal.inner
245245
}
246246
}
247247

src/extjson/de.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ impl TryFrom<serde_json::Map<String, serde_json::Value>> for Bson {
146146

147147
if obj.contains_key("$minKey") {
148148
let min_key: models::MinKey = serde_json::from_value(obj.into())?;
149-
return Ok(min_key.parse()?);
149+
return min_key.parse();
150150
}
151151

152152
if obj.contains_key("$maxKey") {
153153
let max_key: models::MaxKey = serde_json::from_value(obj.into())?;
154-
return Ok(max_key.parse()?);
154+
return max_key.parse();
155155
}
156156

157157
if obj.contains_key("$dbPointer") {
@@ -174,7 +174,7 @@ impl TryFrom<serde_json::Map<String, serde_json::Value>> for Bson {
174174

175175
if obj.contains_key("$undefined") {
176176
let undefined: models::Undefined = serde_json::from_value(obj.into())?;
177-
return Ok(undefined.parse()?);
177+
return undefined.parse();
178178
}
179179

180180
Ok(Bson::Document(obj.try_into()?))

0 commit comments

Comments
 (0)