Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
rust: types: make doctests compilable/testable
Browse files Browse the repository at this point in the history
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: Martin Rodriguez Reboredo <[email protected]>
Reviewed-by: David Gow <[email protected]>
Reviewed-by: Björn Roy Baron <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Signed-off-by: Miguel Ojeda <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
ojeda authored and shuahkh committed Jul 19, 2023
1 parent bfa7dff commit ed615fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rust/kernel/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ForeignOwnable for () {
/// In the example below, we have multiple exit paths and we want to log regardless of which one is
/// taken:
/// ```
/// # use kernel::ScopeGuard;
/// # use kernel::types::ScopeGuard;
/// fn example1(arg: bool) {
/// let _log = ScopeGuard::new(|| pr_info!("example1 completed\n"));
///
Expand All @@ -127,7 +127,7 @@ impl ForeignOwnable for () {
/// In the example below, we want to log the same message on all early exits but a different one on
/// the main exit path:
/// ```
/// # use kernel::ScopeGuard;
/// # use kernel::types::ScopeGuard;
/// fn example2(arg: bool) {
/// let log = ScopeGuard::new(|| pr_info!("example2 returned early\n"));
///
Expand All @@ -148,7 +148,7 @@ impl ForeignOwnable for () {
/// 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`]:
/// ```
/// # use kernel::ScopeGuard;
/// # use kernel::types::ScopeGuard;
/// fn example3(arg: bool) -> Result {
/// let mut vec =
/// ScopeGuard::new_with_data(Vec::new(), |v| pr_info!("vec had {} elements\n", v.len()));
Expand Down

0 comments on commit ed615fb

Please sign in to comment.