Skip to content

Commit 33b69c5

Browse files
committed
fix doctests
1 parent 1aa5d08 commit 33b69c5

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/raw/array_buf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ impl RawArrayBuf {
6565
///
6666
/// ```
6767
/// # use bson::error::Error;
68-
/// use bson::raw::{RawArrayBuf, RawDocumentBuf};
68+
/// use bson::raw::{cstr, RawArrayBuf, RawDocumentBuf};
6969
///
7070
/// let mut array = RawArrayBuf::new();
7171
/// array.push("a string");
7272
/// array.push(12_i32);
7373
///
7474
/// let mut doc = RawDocumentBuf::new();
75-
/// doc.append("a key", "a value");
75+
/// doc.append(cstr!("a key"), "a value");
7676
/// array.push(doc.clone());
7777
///
7878
/// let mut iter = array.into_iter();

src/raw/document.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,18 +388,18 @@ impl RawDocument {
388388
/// the key corresponds to a value which isn't a regex.
389389
///
390390
/// ```
391-
/// use bson::{rawdoc, Regex};
391+
/// use bson::{rawdoc, Regex, raw::cstr};
392392
///
393393
/// let doc = rawdoc! {
394394
/// "regex": Regex {
395-
/// pattern: r"end\s*$".into(),
396-
/// options: "i".into(),
395+
/// pattern: cstr!(r"end\s*$").into(),
396+
/// options: cstr!("i").into(),
397397
/// },
398398
/// "bool": true,
399399
/// };
400400
///
401-
/// assert_eq!(doc.get_regex("regex")?.pattern, r"end\s*$");
402-
/// assert_eq!(doc.get_regex("regex")?.options, "i");
401+
/// assert_eq!(doc.get_regex("regex")?.pattern, cstr!(r"end\s*$"));
402+
/// assert_eq!(doc.get_regex("regex")?.options, cstr!("i"));
403403
/// assert!(doc.get_regex("bool").is_err());
404404
/// assert!(doc.get_regex("unknown").is_err());
405405
/// # Ok::<(), Box<dyn std::error::Error>>(())

src/raw/document_buf.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ impl RawDocumentBuf {
183183
/// the documentation for [BindRawBsonRef] for more details.
184184
/// ```
185185
/// # use bson::error::Error;
186-
/// use bson::{doc, raw::{RawBsonRef, RawDocumentBuf}};
186+
/// use bson::{doc, raw::{cstr, RawBsonRef, RawDocumentBuf}};
187187
///
188188
/// let mut doc = RawDocumentBuf::new();
189189
/// // `&str` and `i32` both convert to `RawBsonRef`
190-
/// doc.append("a string", "some string");
191-
/// doc.append("an integer", 12_i32);
190+
/// doc.append(cstr!("a string"), "some string");
191+
/// doc.append(cstr!("an integer"), 12_i32);
192192
///
193193
/// let mut subdoc = RawDocumentBuf::new();
194-
/// subdoc.append("a key", true);
195-
/// doc.append("a borrowed document", &subdoc);
196-
/// doc.append("an owned document", subdoc);
194+
/// subdoc.append(cstr!("a key"), true);
195+
/// doc.append(cstr!("a borrowed document"), &subdoc);
196+
/// doc.append(cstr!("an owned document"), subdoc);
197197
///
198198
/// let expected = doc! {
199199
/// "a string": "some string",

0 commit comments

Comments
 (0)