[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240916233507.11779-1-nells@linux.microsoft.com>
Date: Mon, 16 Sep 2024 23:35:07 +0000
From: Nell Shamrell-Harrington <nells@...ux.microsoft.com>
To: ojeda@...nel.org,
alex.gaynor@...il.com,
wedsonaf@...il.com
Cc: boqun.feng@...il.com,
gary@...yguo.net,
bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me,
a.hindborg@...sung.com,
aliceryhl@...gle.com,
tmgross@...ch.edu,
linux@...i.io,
kernel@...entinobst.de,
kent.overstreet@...il.com,
matthew.d.roper@...el.com,
kartikprajapati987@...il.com,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] rust: Adds examples for the `Either` type
Adds examples for the `Either` type
Suggested-by: Miguel Ojeda <ojeda@...nel.org>
Signed-off-by: Nell Shamrell-Harrington <nells@...ux.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
Powered by blists - more mailing lists