rust/kernel/types.rs | 6 ++++++ 1 file changed, 6 insertions(+)
Adds examples for the `Either` type
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Nell Shamrell-Harrington <nells@linux.microsoft.com>
---
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`.
+/// ```
+/// 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),
--
2.34.1
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@kernel.org> > Signed-off-by: Nell Shamrell-Harrington <nells@linux.microsoft.com> > --- > 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@de.bosch.com> Thanks Dirk
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@kernel.org> > >Signed-off-by: Nell Shamrell-Harrington <nells@linux.microsoft.com> > >--- > > 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@de.bosch.com> Thank you for doing this, I appreciate you taking the time! > > Thanks > > Dirk > >
© 2016 - 2024 Red Hat, Inc.