History

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.

Miguel Ojeda committed 3 years ago

Commit ed615fb1 parent bfa7dff1 file · +3 −3Browse files

Unified · Split

rust/kernel/types.rs+3−3
@@ -109,7 +109,7 @@ impl ForeignOwnable for () { · 108 unmodified lines
109/// In the example below, we have multiple exit paths and we want to log regardless of which one is109/// In the example below, we have multiple exit paths and we want to log regardless of which one is
110/// taken:110/// taken:
111/// ```111/// ```
112/// # use kernel::ScopeGuard;112/// # use kernel::types::ScopeGuard;
113/// fn example1(arg: bool) {113/// fn example1(arg: bool) {
114/// let _log = ScopeGuard::new(|| pr_info!("example1 completed\n"));114/// let _log = ScopeGuard::new(|| pr_info!("example1 completed\n"));
115///115///
@@ -127,7 +127,7 @@ impl ForeignOwnable for () { · 11 unmodified lines
127/// In the example below, we want to log the same message on all early exits but a different one on127/// In the example below, we want to log the same message on all early exits but a different one on
128/// the main exit path:128/// the main exit path:
129/// ```129/// ```
130/// # use kernel::ScopeGuard;130/// # use kernel::types::ScopeGuard;
131/// fn example2(arg: bool) {131/// fn example2(arg: bool) {
132/// let log = ScopeGuard::new(|| pr_info!("example2 returned early\n"));132/// let log = ScopeGuard::new(|| pr_info!("example2 returned early\n"));
133///133///
@@ -148,7 +148,7 @@ impl ForeignOwnable for () { · 14 unmodified lines
148/// In the example below, we need a mutable object (the vector) to be accessible within the log148/// In the example below, we need a mutable object (the vector) to be accessible within the log
149/// function, so we wrap it in the [`ScopeGuard`]:149/// function, so we wrap it in the [`ScopeGuard`]:
150/// ```150/// ```
151/// # use kernel::ScopeGuard;151/// # use kernel::types::ScopeGuard;
152/// fn example3(arg: bool) -> Result {152/// fn example3(arg: bool) -> Result {
153/// let mut vec =153/// let mut vec =
154/// ScopeGuard::new_with_data(Vec::new(), |v| pr_info!("vec had {} elements\n", v.len()));154/// ScopeGuard::new_with_data(Vec::new(), |v| pr_info!("vec had {} elements\n", v.len()));