public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: Adds examples for the `Either` type
@ 2024-09-16 23:35 Nell Shamrell-Harrington
  2024-09-17  8:35 ` Dirk Behme
  0 siblings, 1 reply; 3+ messages in thread
From: Nell Shamrell-Harrington @ 2024-09-16 23:35 UTC (permalink / raw)
  To: ojeda, alex.gaynor, wedsonaf
  Cc: boqun.feng, gary, bjorn3_gh, benno.lossin, a.hindborg, aliceryhl,
	tmgross, linux, kernel, kent.overstreet, matthew.d.roper,
	kartikprajapati987, rust-for-linux, linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: Adds examples for the `Either` type
  2024-09-16 23:35 [PATCH] rust: Adds examples for the `Either` type Nell Shamrell-Harrington
@ 2024-09-17  8:35 ` Dirk Behme
  2024-09-17 18:01   ` Nell Shamrell-Harrington
  0 siblings, 1 reply; 3+ messages in thread
From: Dirk Behme @ 2024-09-17  8:35 UTC (permalink / raw)
  To: Nell Shamrell-Harrington, ojeda, alex.gaynor, wedsonaf
  Cc: boqun.feng, gary, bjorn3_gh, benno.lossin, a.hindborg, aliceryhl,
	tmgross, linux, kernel, kent.overstreet, matthew.d.roper,
	kartikprajapati987, rust-for-linux, linux-kernel

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: Adds examples for the `Either` type
  2024-09-17  8:35 ` Dirk Behme
@ 2024-09-17 18:01   ` Nell Shamrell-Harrington
  0 siblings, 0 replies; 3+ messages in thread
From: Nell Shamrell-Harrington @ 2024-09-17 18:01 UTC (permalink / raw)
  To: Dirk Behme
  Cc: ojeda, alex.gaynor, wedsonaf, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl, tmgross, linux, kernel,
	kent.overstreet, matthew.d.roper, kartikprajapati987,
	rust-for-linux, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-17 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 23:35 [PATCH] rust: Adds examples for the `Either` type Nell Shamrell-Harrington
2024-09-17  8:35 ` Dirk Behme
2024-09-17 18:01   ` Nell Shamrell-Harrington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox