Rust in the 6.2 kernel
Rust in the 6.2 kernel
Posted Nov 24, 2022 1:48 UTC (Thu) by atnot (guest, #124910)In reply to: Rust in the 6.2 kernel by gasche
Parent article: Rust in the 6.2 kernel
That is my problem with Either though. It's too vague to enable any reuse at all. I think a look at the associated functions of Option and Result in rust compared to the Either crate illustrate that quite clearly.
Option and Result have dozens of combinators each that compose usefully. You can turn Results into Options, Options into Results, Options into Iterators, Results of Options into Results, Iterators of Options into Options, Iterators of Results into Results...
Meanwhile on the Either side we get:
(https://docs.rs/either/1.8.0/either/enum.Either.html)
- A few map variations, duplicated for left and right of course
- Some forwarding of inner traits
- A bunch of methods that turn it back into the more useful Option and Result types
- Flip, that swaps the sides
This is not a swipe against the authors. It just shows you just can't really do very much with types that are completely unconstrained and semantically meaningless.
