Skip to content

Commit 35c3d19

Browse files
committed
Code review fixes
1 parent b516f7e commit 35c3d19

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

#test#

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rocket in the sky, don't ask me why
2+

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ This crate works with Cargo and can be found on
1616

1717
```toml
1818
[dependencies]
19-
bson = "*"
19+
bson = "0.3.2"
2020
```
2121
## Usage
22+
Link the library in _main.rs_:
23+
```rust
24+
#[macro_use(bson, doc)]
25+
extern crate bson;
26+
```
2227

2328
Prepare your struct for Serde serialization:
2429
```rust
@@ -42,19 +47,19 @@ let person = Person {
4247
};
4348

4449
let serialized_person = bson::to_bson(&person)?; // Serialize
45-
46-
if let bson::Bson::Document(document) = serialized {
50+
51+
if let bson::Bson::Document(document) = serialized_person {
4752
mongoCollection.insert_one(document, None)?; // Insert into a MongoDB collection
4853
} else {
49-
println!("Error converting the BSON object into a MongoDB document")
54+
println!("Error converting the BSON object into a MongoDB document");
5055
}
5156
```
5257

5358
Deserialize the struct:
5459
```rust
5560
// Read the document from a MongoDB collection
5661
let person_document = mongoCollection.find_one(Some(doc! { "_id" => "12345" }), None)?
57-
.expect("Document not found")
62+
.expect("Document not found");
5863

5964
// Deserialize the document into a Person instance
6065
let person = bson::from_bson(bson::Bson::Document(person_document))?

0 commit comments

Comments
 (0)