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

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