2 ms·
As a related concept, we've talked about adding "pattern types" to Rust: `Result<T> is Err(_)` (the type of a Result that you've just confirmed is an `Err`, so
by JoshTriplett 2y ago
As a related concept, we've talked about adding "pattern types" to Rust: `Result<T> is Err(_)` (the type of a Result that you've just confirmed is an `Err`, so you don't have to handle the `Ok` case), or `u32 is 1..` (equivalent to `NonZero<u32>` but more flexible).
- bonzini 2y agoIs the former different from a hypothetical Result::Err type (I don't know if you'd spell that Result::Err<T> or Result::<T>::Err)?
- JoshTriplett 2y agoSame concept, but generalized to any type, not just enums.
- n_plus_1_acc 2y agoDifferent solutions to the same problem. Pattern types are more general than enum variant types.