operator == method
Compare equality between two Result
values.
Result
values are considered equal if the values they hold are equal,
or if they hold references to the same object (identical()). When comparing
Ok values, the type of E
will be elided, and T
will be elided when
comparing Err values.
This means that Ok<int, String>(1) is equal to Ok<int, int>(1) and Err<int, String>('foo') is equal to Err<bool, String>('foo') because their held values are equatable and their irrelevant types are elided.
Implementation
@override
operator ==(Object other) => switch (other) {
Ok(value: T value) when isOk() => identical(value, unwrap()) || value == unwrap(),
Err(value: E err) when isErr() => identical(err, unwrapErr()) || err == unwrapErr(),
_ => false
};