Commit ed615fb8 authored by Miguel Ojeda's avatar Miguel Ojeda Committed by Shuah Khan

rust: types: 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: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Reviewed-by: default avatarBjörn Roy Baron <bjorn3_gh@protonmail.com>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent bfa7dff0
...@@ -109,7 +109,7 @@ unsafe fn from_foreign(_: *const core::ffi::c_void) -> Self {} ...@@ -109,7 +109,7 @@ unsafe fn from_foreign(_: *const core::ffi::c_void) -> Self {}
/// In the example below, we have multiple exit paths and we want to log regardless of which one is /// In the example below, we have multiple exit paths and we want to log regardless of which one is
/// taken: /// taken:
/// ``` /// ```
/// # use kernel::ScopeGuard; /// # use kernel::types::ScopeGuard;
/// fn example1(arg: bool) { /// fn example1(arg: bool) {
/// let _log = ScopeGuard::new(|| pr_info!("example1 completed\n")); /// let _log = ScopeGuard::new(|| pr_info!("example1 completed\n"));
/// ///
...@@ -127,7 +127,7 @@ unsafe fn from_foreign(_: *const core::ffi::c_void) -> Self {} ...@@ -127,7 +127,7 @@ unsafe fn from_foreign(_: *const core::ffi::c_void) -> Self {}
/// In the example below, we want to log the same message on all early exits but a different one on /// In the example below, we want to log the same message on all early exits but a different one on
/// the main exit path: /// the main exit path:
/// ``` /// ```
/// # use kernel::ScopeGuard; /// # use kernel::types::ScopeGuard;
/// fn example2(arg: bool) { /// fn example2(arg: bool) {
/// let log = ScopeGuard::new(|| pr_info!("example2 returned early\n")); /// let log = ScopeGuard::new(|| pr_info!("example2 returned early\n"));
/// ///
...@@ -148,7 +148,7 @@ unsafe fn from_foreign(_: *const core::ffi::c_void) -> Self {} ...@@ -148,7 +148,7 @@ unsafe fn from_foreign(_: *const core::ffi::c_void) -> Self {}
/// In the example below, we need a mutable object (the vector) to be accessible within the log /// In the example below, we need a mutable object (the vector) to be accessible within the log
/// function, so we wrap it in the [`ScopeGuard`]: /// function, so we wrap it in the [`ScopeGuard`]:
/// ``` /// ```
/// # use kernel::ScopeGuard; /// # use kernel::types::ScopeGuard;
/// fn example3(arg: bool) -> Result { /// fn example3(arg: bool) -> Result {
/// let mut vec = /// let mut vec =
/// ScopeGuard::new_with_data(Vec::new(), |v| pr_info!("vec had {} elements\n", v.len())); /// ScopeGuard::new_with_data(Vec::new(), |v| pr_info!("vec had {} elements\n", v.len()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment