From: Nell Shamrell-Harrington <nells@linux.microsoft.com>
To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com
Cc: boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
benno.lossin@proton.me, a.hindborg@samsung.com,
aliceryhl@google.com, tmgross@umich.edu, linux@obei.io,
kernel@valentinobst.de, kent.overstreet@gmail.com,
matthew.d.roper@intel.com, kartikprajapati987@gmail.com,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] rust: Adds examples for the `Either` type
Date: Mon, 16 Sep 2024 23:35:07 +0000 [thread overview]
Message-ID: <20240916233507.11779-1-nells@linux.microsoft.com> (raw)
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
next reply other threads:[~2024-09-16 23:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 23:35 Nell Shamrell-Harrington [this message]
2024-09-17 8:35 ` [PATCH] rust: Adds examples for the `Either` type Dirk Behme
2024-09-17 18:01 ` Nell Shamrell-Harrington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240916233507.11779-1-nells@linux.microsoft.com \
--to=nells@linux.microsoft.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=kartikprajapati987@gmail.com \
--cc=kent.overstreet@gmail.com \
--cc=kernel@valentinobst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@obei.io \
--cc=matthew.d.roper@intel.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox