[PATCH] rust: Adds examples for the `Either` type
From: Nell Shamrell-Harrington
Date: Mon Sep 16 2024 - 19:35:30 EST
Adds examples for the `Either` type
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`.
+/// ```
+/// 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