Re: [PATCH] rust: Adds examples for the `Either` type
From: Dirk Behme
Date: Tue Sep 17 2024 - 04:36:36 EST
On 17.09.2024 01:35, Nell Shamrell-Harrington wrote:
Adds examples for the `Either` type
You might want to check
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
"Describe your changes in imperative mood, e.g. “make xyzzy do frotz”
instead of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to
do frotz”, as if you are giving orders to the codebase to change its
behaviour."
For example:
[PATCH] rust: types: Add examples for the `Either` type
Add examples for the `Either` types.
Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Signed-off-by: Nell Shamrell-Harrington <nells@xxxxxxxxxxxxxxxxxxx>
---
rust/kernel/types.rs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
index 9e7ca066355c..f22f6e289198 100644
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@ -461,6 +461,12 @@ fn drop(&mut self) {
}
/// A sum type that always holds either a value of type `L` or `R`.
It looks to me that the default is to add
/// # Examples
followed by some verbose explanation before the test code below.
+/// ```
+/// use kernel::types::Either;
+///
+/// let left_value: Either<i32, &str> = Either::Left(7);
+/// let right_value: Either<i32, &str> = Either::Right("right value");
+/// ```
I ran that on the the target and got:
# rust_doctest_kernel_types_rs_3.location: rust/kernel/types.rs:485
ok 107 rust_doctest_kernel_types_rs_3
So:
Tested-by: Dirk Behme <dirk.behme@xxxxxxxxxxxx>
Thanks
Dirk