3 ms·
I'm not sure if all your examples were meant to be things that Rust doesn't have, but Rust certainly has polymorphic return values. For example, see the `Defaul
by burntsushi 13y ago
I'm not sure if all your examples were meant to be things that Rust doesn't have, but Rust certainly has polymorphic return values. For example, see the `Default` trait: http://static.rust-lang.org/doc/master/std/default/trait.Default.html http://static.rust-lang.org/doc/master/std/default/trait.Def...
It's also used to generate random values: http://static.rust-lang.org/doc/master/rand/trait.Rng.html http://static.rust-lang.org/doc/master/rand/trait.Rng.html
More generally, Rust supports polymorphism anywhere. e.g., The `Eq` trait: http://static.rust-lang.org/doc/master/std/cmp/trait.Eq.html http://static.rust-lang.org/doc/master/std/cmp/trait.Eq.html
AFAIK, >1-arity polymorphism in OOP languages is generally achieved with double dispatch. But it's not as nice (or as easy to understand IMO) as in ad hoc polymorphism.
Rust does not have HKT or multi-param traits though.