Either represents a result with exactly two alternatives: Success containing a value or Failure containing an error message. As a sum type, it makes success-or-failure states explicit and gives Rust's pattern matching a clear target. section 7.3
A minimal Either-based workflow:
- Define enum Either<T> with Success(T) and Failure(String) variants. section 7.3
- Return Either from a calculation instead of hiding whether it succeeded. section 7.3
- Match on the variants to handle the result explicitly. section 7.3
- Map a successful value while leaving failures unchanged. section 7.3
enum Either<T> {
Success(T),
Failure(String),
}
Inspect the compact enum definition that gives Either its two-state structure. section 7.3



