mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-07 10:29:52 +00:00
Introduce the new `types` module of the `kernel` crate with
`Either` as its first type.
`Either<L, R>` is a sum type that always holds either a value
of type `L` (`Left` variant) or `R` (`Right` variant).
For instance:
struct Executor {
queue: Either<BoxedQueue, &'static Queue>,
}
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com>
Reviewed-by: Wei Liu <wei.liu@kernel.org>
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
13 lines
332 B
Rust
13 lines
332 B
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//! Kernel types.
|
|
|
|
/// A sum type that always holds either a value of type `L` or `R`.
|
|
pub enum Either<L, R> {
|
|
/// Constructs an instance of [`Either`] containing a value of type `L`.
|
|
Left(L),
|
|
|
|
/// Constructs an instance of [`Either`] containing a value of type `R`.
|
|
Right(R),
|
|
}
|