rust: types: add `Either` type
authorWedson Almeida Filho <wedsonaf@gmail.com>
Thu, 10 Nov 2022 16:41:39 +0000 (17:41 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 4 Dec 2022 00:59:16 +0000 (01:59 +0100)
commitba20915bae49024dab6ee582abdd4cd8944a3e55
tree58941383549263a3d2e39312d5c339a16a4296c4
parent0f595bab9d1c1a10c6ab5ff3f9140cfc26600349
rust: types: add `Either` type

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>
rust/kernel/lib.rs
rust/kernel/types.rs [new file with mode: 0644]