@@ -154,33 +154,31 @@ e.g.:
154
154
#[derive(Serialize , Deserialize )]
155
155
struct Person {
156
156
name : String ,
157
- age : u8 ,
157
+ age : i32 ,
158
158
phones : Vec <String >,
159
159
}
160
160
161
- fn typed_example () {
162
- // Some BSON input data as a `Bson`.
163
- let bson_data : Bson = bson! ({
164
- " name" : " John Doe" ,
165
- " age" : 43 ,
166
- " phones" : [
167
- " +44 1234567" ,
168
- " +44 2345678"
169
- ]
170
- });
171
-
172
- // Deserialize the Person struct from the BSON data, automatically
173
- // verifying that the necessary keys are present and that they are of
174
- // the correct types.
175
- let mut person : Person = bson :: from_bson (bson_data ). unwrap ();
176
-
177
- // Do things just like with any other Rust data structure.
178
- println! (" Redacting {}'s record." , person . name);
179
- person . name = " REDACTED" . to_string ();
180
-
181
- // Get a serialized version of the input data as a `Bson`.
182
- let redacted_bson = bson :: to_bson (& person ). unwrap ();
183
- }
161
+ // Some BSON input data as a `Bson`.
162
+ let bson_data : Bson = bson! ({
163
+ " name" : " John Doe" ,
164
+ " age" : 43 ,
165
+ " phones" : [
166
+ " +44 1234567" ,
167
+ " +44 2345678"
168
+ ]
169
+ });
170
+
171
+ // Deserialize the Person struct from the BSON data, automatically
172
+ // verifying that the necessary keys are present and that they are of
173
+ // the correct types.
174
+ let mut person : Person = bson :: from_bson (bson_data ). unwrap ();
175
+
176
+ // Do things just like with any other Rust data structure.
177
+ println! (" Redacting {}'s record." , person . name);
178
+ person . name = " REDACTED" . to_string ();
179
+
180
+ // Get a serialized version of the input data as a `Bson`.
181
+ let redacted_bson = bson :: to_bson (& person ). unwrap ();
184
182
```
185
183
186
184
Any types that implement ` Serialize ` and ` Deserialize ` can be used in this way. Doing so helps
@@ -241,4 +239,3 @@ bash .evergreen/check-clippy.sh && bash .evergreen/check-rustfmt.sh
241
239
242
240
## Continuous Integration
243
241
Commits to master are run automatically on [ evergreen] ( https://evergreen.mongodb.com/waterfall/rust-bson ) .
244
-
0 commit comments