Re: [PATCH] rust: Adds examples for the `Either` type

From: Nell Shamrell-Harrington
Date: Tue Sep 17 2024 - 14:01:27 EST


On Tue, Sep 17, 2024 at 10:35:20AM +0200, Dirk Behme wrote:
> 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.

Will do!

>
>
> >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

Thank you, I will add this in and resubmit the patch.

>
> 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>

Thank you for doing this, I appreciate you taking the time!

>
> Thanks
>
> Dirk
>
>