Rust in the 6.2 kernel
Rust in the 6.2 kernel
Posted Nov 20, 2022 14:57 UTC (Sun) by atnot (guest, #124910)In reply to: Rust in the 6.2 kernel by gasche
Parent article: Rust in the 6.2 kernel
This is somewhat unrelated to the rest of your question, but I personally really don't agree. Rust core already has types for Option and Result, which are the common case for things that can be one of two types. But to me the Either type ends up simultaneously too broad and specific compared to just defining your own enum. The generic "left" and "right" names are cryptic and confusing, there is little commonality betwen users and it has worse type safety and error reporting. It also lacks extensibility by only offering two variants, making for a painful refactoring if you notice you do need three options after all. Lastly a lot of the time when a function can take multiple things, those things usually share some property which can perhaps be better represented by a trait.
