Skip to content

Commit 2875321

Browse files
BennoLossinojeda
authored andcommitted
rust: types: remove Either<L, R>
This enum is not used. Additionally, using it would result in poor ergonomics, because in order to do any operation on a value it has to be matched first. Our version of `Either` also doesn't provide any helper methods making it even more difficult to use. The alternative of creating a custom enum for the concrete use-case also is much better for ergonomics. As one can provide functions on the type directly and users don't need to match the value manually. Signed-off-by: Benno Lossin <[email protected]> Reviewed-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 1523590 commit 2875321

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

rust/kernel/types.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -569,24 +569,6 @@ impl<T: AlwaysRefCounted> Drop for ARef<T> {
569569
}
570570
}
571571

572-
/// A sum type that always holds either a value of type `L` or `R`.
573-
///
574-
/// # Examples
575-
///
576-
/// ```
577-
/// use kernel::types::Either;
578-
///
579-
/// let left_value: Either<i32, &str> = Either::Left(7);
580-
/// let right_value: Either<i32, &str> = Either::Right("right value");
581-
/// ```
582-
pub enum Either<L, R> {
583-
/// Constructs an instance of [`Either`] containing a value of type `L`.
584-
Left(L),
585-
586-
/// Constructs an instance of [`Either`] containing a value of type `R`.
587-
Right(R),
588-
}
589-
590572
/// Zero-sized type to mark types not [`Send`].
591573
///
592574
/// Add this type as a field to your struct if your type should not be sent to a different task.

0 commit comments

Comments
 (0)