Skip to content

Commit cc7ba19

Browse files
committed
fix doctests
1 parent 8126d69 commit cc7ba19

File tree

8 files changed

+16
-30
lines changed

8 files changed

+16
-30
lines changed

src/action.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ pub trait Action: private::Sealed + IntoFuture {
8888
/// If the value is `Some`, call the provided function on `self`. Convenient for chained
8989
/// updates with values that need to be set conditionally. For example:
9090
/// ```rust
91-
/// # use mongodb::{Client, error::Result};
92-
/// # use bson::Document;
91+
/// # use mongodb::{Client, error::Result, bson::Document};
9392
/// use mongodb::action::Action;
9493
/// async fn list_my_collections(client: &Client, filter: Option<Document>) -> Result<Vec<String>> {
9594
/// client.database("my_db")

src/change_stream/session.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ where
7474
/// The session provided must be the same session used to create the change stream.
7575
///
7676
/// ```
77-
/// # use bson::{doc, Document};
78-
/// # use mongodb::Client;
77+
/// # use mongodb::{Client, bson::{self, doc, Document}};
7978
/// # fn main() {
8079
/// # async {
8180
/// # let client = Client::with_uri_str("foo").await?;

src/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ impl Client {
195195
/// Return an `EncryptedClientBuilder` for constructing a `Client` with auto-encryption enabled.
196196
///
197197
/// ```no_run
198-
/// # use bson::doc;
199198
/// # use mongocrypt::ctx::KmsProvider;
200-
/// # use mongodb::Client;
201-
/// # use mongodb::error::Result;
199+
/// # use mongodb::{Client, bson::{self, doc}, error::Result};
202200
/// # async fn func() -> Result<()> {
203201
/// # let client_options = todo!();
204202
/// # let key_vault_namespace = todo!();
@@ -207,7 +205,7 @@ impl Client {
207205
/// let encrypted_client = Client::encrypted_builder(
208206
/// client_options,
209207
/// key_vault_namespace,
210-
/// [(KmsProvider::Local, doc! { "key": local_key }, None)],
208+
/// [(KmsProvider::local(), doc! { "key": local_key }, None)],
211209
/// )?
212210
/// .key_vault_client(key_vault_client)
213211
/// .build()

src/client/csfle/client_builder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ use super::options::AutoEncryptionOptions;
77
/// A builder for constructing a `Client` with auto-encryption enabled.
88
///
99
/// ```no_run
10-
/// # use bson::doc;
1110
/// # use mongocrypt::ctx::KmsProvider;
12-
/// # use mongodb::Client;
13-
/// # use mongodb::error::Result;
11+
/// # use mongodb::{Client, bson::{self, doc}, error::Result};
1412
/// # async fn func() -> Result<()> {
1513
/// # let client_options = todo!();
1614
/// # let key_vault_namespace = todo!();
@@ -19,7 +17,7 @@ use super::options::AutoEncryptionOptions;
1917
/// let encrypted_client = Client::encrypted_builder(
2018
/// client_options,
2119
/// key_vault_namespace,
22-
/// [(KmsProvider::Local, doc! { "key": local_key }, None)],
20+
/// [(KmsProvider::local(), doc! { "key": local_key }, None)],
2321
/// )?
2422
/// .key_vault_client(key_vault_client)
2523
/// .build()

src/client/csfle/client_encryption.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ impl ClientEncryption {
3939
/// Initialize a new `ClientEncryption`.
4040
///
4141
/// ```no_run
42-
/// # use bson::doc;
4342
/// # use mongocrypt::ctx::KmsProvider;
44-
/// # use mongodb::client_encryption::ClientEncryption;
45-
/// # use mongodb::error::Result;
43+
/// # use mongodb::{bson::doc, client_encryption::ClientEncryption, error::Result};
4644
/// # fn func() -> Result<()> {
4745
/// # let kv_client = todo!();
4846
/// # let kv_namespace = todo!();
@@ -51,8 +49,8 @@ impl ClientEncryption {
5149
/// kv_client,
5250
/// kv_namespace,
5351
/// [
54-
/// (KmsProvider::Local, doc! { "key": local_key }, None),
55-
/// (KmsProvider::Kmip, doc! { "endpoint": "localhost:5698" }, None),
52+
/// (KmsProvider::local(), doc! { "key": local_key }, None),
53+
/// (KmsProvider::kmip(), doc! { "endpoint": "localhost:5698" }, None),
5654
/// ]
5755
/// )?;
5856
/// # Ok(())
@@ -72,10 +70,8 @@ impl ClientEncryption {
7270
/// [`ClientEncryptionBuilder`] can be chained to set options.
7371
///
7472
/// ```no_run
75-
/// # use bson::doc;
7673
/// # use mongocrypt::ctx::KmsProvider;
77-
/// # use mongodb::client_encryption::ClientEncryption;
78-
/// # use mongodb::error::Result;
74+
/// # use mongodb::{bson::doc, client_encryption::ClientEncryption, error::Result};
7975
/// # fn func() -> Result<()> {
8076
/// # let kv_client = todo!();
8177
/// # let kv_namespace = todo!();
@@ -84,8 +80,8 @@ impl ClientEncryption {
8480
/// kv_client,
8581
/// kv_namespace,
8682
/// [
87-
/// (KmsProvider::Local, doc! { "key": local_key }, None),
88-
/// (KmsProvider::Kmip, doc! { "endpoint": "localhost:5698" }, None),
83+
/// (KmsProvider::local(), doc! { "key": local_key }, None),
84+
/// (KmsProvider::kmip(), doc! { "endpoint": "localhost:5698" }, None),
8985
/// ]
9086
/// )
9187
/// .build()?;

src/cursor/session.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ where
117117
/// the stream before using the session.
118118
///
119119
/// ```
120-
/// # use bson::{doc, Document};
121-
/// # use mongodb::{Client, error::Result};
120+
/// # use mongodb::{Client, bson::{doc, Document}, error::Result};
122121
/// # fn main() {
123122
/// # async {
124123
/// # let client = Client::with_uri_str("foo").await?;
@@ -165,8 +164,7 @@ where
165164
/// functionality of `Stream` is not needed.
166165
///
167166
/// ```
168-
/// # use bson::{doc, Document};
169-
/// # use mongodb::Client;
167+
/// # use mongodb::{Client, bson::{doc, Document}};
170168
/// # fn main() {
171169
/// # async {
172170
/// # let client = Client::with_uri_str("foo").await?;

src/sync/change_stream.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ where
181181
/// The session provided must be the same session used to create the change stream.
182182
///
183183
/// ```
184-
/// # use bson::{doc, Document};
185-
/// # use mongodb::sync::Client;
184+
/// # use mongodb::{bson::{self, doc, Document}, sync::Client};
186185
/// # fn main() {
187186
/// # async {
188187
/// # let client = Client::with_uri_str("foo")?;

src/sync/cursor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ where
320320
/// functionality of `Iterator` is not needed.
321321
///
322322
/// ```
323-
/// # use bson::{doc, Document};
324-
/// # use mongodb::sync::Client;
323+
/// # use mongodb::{bson::{doc, Document}, sync::Client};
325324
/// # fn foo() -> mongodb::error::Result<()> {
326325
/// # let client = Client::with_uri_str("foo")?;
327326
/// # let coll = client.database("foo").collection::<Document>("bar");

0 commit comments

Comments
 (0)