The futures crate already provides an either for that case.
Yes, but impl Trait is not just for futures. It is now a core language feature, should have good library support as well.
I think we should consider extending the language with anonymous sum types instead.
A lot of the frunk crate is essentially a hack around that.
A|B types?
Yes, those; See also https://github.com/rust-lang/rfcs/issues/294
Huh. I’d’ve thought the syntax would be more like:
let x = (&str, i32, i32)::2(1);
match x {
<x>::0(s) => ...,
<x>::1(i) => ...,
<x>::2(j) => ...,
}
But okay… (this would be the opposite of a tuple - while a tuple’s attribute operates on values (t.0, t.1, etc), a summer’s attribute operates on types (T::0, T::1, etc))
(alternatively it wouldn’t support repeated types at all and construction and matching would be trivial)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.