Skip to content

Commit a8804a9

Browse files
committed
review updates
1 parent b255d5a commit a8804a9

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/raw/array_buf.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,19 @@ impl TryFrom<&crate::Array> for RawArrayBuf {
189189
type Error = crate::error::Error;
190190

191191
fn try_from(value: &crate::Array) -> Result<Self, Self::Error> {
192-
let mut tmp = RawArrayBuf::new();
193-
for val in value {
194-
let raw: super::RawBson = val.clone().try_into()?;
195-
tmp.push(raw)?;
196-
}
197-
Ok(tmp)
192+
Self::try_from(value.clone())
198193
}
199194
}
200195

201196
impl TryFrom<crate::Array> for RawArrayBuf {
202197
type Error = crate::error::Error;
203198

204199
fn try_from(value: crate::Array) -> Result<Self, Self::Error> {
205-
Self::try_from(&value)
200+
let mut tmp = RawArrayBuf::new();
201+
for val in value {
202+
let raw: super::RawBson = val.try_into()?;
203+
tmp.push(raw)?;
204+
}
205+
Ok(tmp)
206206
}
207207
}

src/raw/document_buf.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl RawDocumentBuf {
116116
/// ```
117117
pub fn from_document(doc: impl Borrow<Document>) -> Result<Self> {
118118
let mut out = RawDocumentBuf::new();
119-
for (k, v) in doc {
119+
for (k, v) in doc.borrow() {
120120
let val: RawBson = v.clone().try_into()?;
121121
out.append(k, val)?;
122122
}
@@ -285,7 +285,12 @@ impl TryFrom<Document> for RawDocumentBuf {
285285
type Error = crate::error::Error;
286286

287287
fn try_from(doc: Document) -> std::result::Result<Self, Self::Error> {
288-
Self::try_from(&doc)
288+
let mut out = RawDocumentBuf::new();
289+
for (k, v) in doc {
290+
let val: RawBson = v.try_into()?;
291+
out.append(k, val)?;
292+
}
293+
Ok(out)
289294
}
290295
}
291296

0 commit comments

Comments
 (0)