From: Nell Shamrell-Harrington Date: Wed, 18 Sep 2024 21:20:52 +0000 (+0000) Subject: rust: types: add examples for the `Either` type X-Git-Tag: microblaze-v6.16~535^2~80 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=d407317076ce1ce5ec0882f08d619c0dd79a5fbf;p=linux-2.6-microblaze.git rust: types: add examples for the `Either` type We aim to have examples in all Rust types, thus add basic ones for the `Either` type. Suggested-by: Miguel Ojeda Signed-off-by: Nell Shamrell-Harrington Tested-by: Dirk Behme Reviewed-by: Trevor Gross Reviewed-by: Alice Ryhl Link: https://rust-for-linux.zulipchat.com/#narrow/stream/291565/topic/x/near/467478085 Link: https://lore.kernel.org/r/20240918212052.8790-1-nells@linux.microsoft.com [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs index 9e7ca066355c..e2f3ab11cfda 100644 --- a/rust/kernel/types.rs +++ b/rust/kernel/types.rs @@ -461,6 +461,15 @@ impl Drop for ARef { } /// A sum type that always holds either a value of type `L` or `R`. +/// +/// # Examples +/// +/// ``` +/// use kernel::types::Either; +/// +/// let left_value: Either = Either::Left(7); +/// let right_value: Either = Either::Right("right value"); +/// ``` pub enum Either { /// Constructs an instance of [`Either`] containing a value of type `L`. Left(L),