rust: Adds examples for the `Either` type
PATCH 1/1 rust: Adds examples for the `Either` type
Adds examples for the Either type
--- rust/kernel/types.rs | 6 ++++++ 1 file changed, 6 insertions(+)
rust/kernel/types.rs +6 -0
@@ -461,6 +461,12 @@ fn drop(&mut self) { }/// A sum type that always holds either a value of type `L` or `R`. +/// ``` +/// use kernel::types::Either; +/// +/// let left_value: Either<i32, &str> = Either::Left(7); +/// let right_value: Either<i32, &str> = Either::Right("right value"); +/// ``` pub enum Either <L ,R > {/// Constructs an instance of [`Either`] containing a value of type `L`. Left (L ),
Signature · 1 line
2.34.1
Quoted 1 line · Nell Shamrell-Harrington
Adds examples for the
Eithertype
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.
Quoted 11 lines
Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Nell Shamrell-Harrington <[email protected]>--- rust/kernel/types.rs | 6 ++++++ 1 file changed, 6 insertions(+)rust/kernel/types.rs +0
-0
rust/kernel/types.rs fn drop(&mut self) { · line 463
Quoted 3 lines
rust/kernel/types.rs +0
-0@@ -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.
rust/kernel/types.rs fn drop(&mut self) { · line 469
Quoted 6 lines
rust/kernel/types.rs +6
-0+/// ``` +/// 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:
Thanks
Dirk
Quoted 12 lines · Dirk Behme
Quoted 1 line · Nell Shamrell-Harrington
Adds examples for the
EithertypeYou 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."
Quoted 5 lines
For example:
[PATCH] rust: types: Add examples for the
EithertypeAdd examples for the
Eithertypes.
Will do!
Quoted 18 lines
Quoted 13 lines
Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Nell Shamrell-Harrington <[email protected]>--- rust/kernel/types.rs | 6 ++++++ 1 file changed, 6 insertions(+)rust/kernel/types.rs +0
-0rust/kernel/types.rs fn drop(&mut self) { · line 462
Quoted 2 lines
rust/kernel/types.rs +0
-0@@ -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
Quoted 1 line
/// # Examples
Thank you, I will add this in and resubmit the patch.
Quoted 12 lines
followed by some verbose explanation before the test code below.
rust/kernel/types.rs fn drop(&mut self) { · line 469
Quoted 6 lines
rust/kernel/types.rs +6
-0+/// ``` +/// 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:
Quoted 6 lines
# rust_doctest_kernel_types_rs_3.location:
rust/kernel/types.rs:485ok 107rust_doctest_kernel_types_rs_3So:
Tested-by Dirk Behme <[email protected]>
Thank you for doing this, I appreciate you taking the time!
Quoted 6 lines
Thanks
Dirk