Skip to content

Commit cf36a49

Browse files
ojedashuahkh
authored andcommitted
rust: str: make doctests compilable/testable
Rust documentation tests are going to be build/run-tested with the KUnit integration added in a future patch, thus update them to make them compilable/testable so that we may start enforcing it. Reviewed-by: Björn Roy Baron <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent a30e94c commit cf36a49

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rust/kernel/str.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl fmt::Display for CStr {
213213
///
214214
/// ```
215215
/// # use kernel::c_str;
216+
/// # use kernel::fmt;
216217
/// # use kernel::str::CStr;
217218
/// # use kernel::str::CString;
218219
/// let penguin = c_str!("🐧");
@@ -241,6 +242,7 @@ impl fmt::Debug for CStr {
241242
///
242243
/// ```
243244
/// # use kernel::c_str;
245+
/// # use kernel::fmt;
244246
/// # use kernel::str::CStr;
245247
/// # use kernel::str::CString;
246248
/// let penguin = c_str!("🐧");
@@ -529,7 +531,7 @@ impl fmt::Write for Formatter {
529531
/// # Examples
530532
///
531533
/// ```
532-
/// use kernel::str::CString;
534+
/// use kernel::{str::CString, fmt};
533535
///
534536
/// let s = CString::try_from_fmt(fmt!("{}{}{}", "abc", 10, 20)).unwrap();
535537
/// assert_eq!(s.as_bytes_with_nul(), "abc1020\0".as_bytes());

0 commit comments

Comments
 (0)