Re:Comparing Rust and Java
by jmgrosen on Sunday February 28, 2016 @11:33PM
(#11193602)
A minor point on a great article, but "On the other hand, Java’s enum values are really singleton classes under the hood – so one can define an abstract method in the enum to implement differently in each value, something that would require a match expression (or hash-table, whose construction at compile time some enterprising Rustaceans have built a crate for) in Rust" isn't quite true -- you can implement methods on enums in Rust, too: http://is.gd/M3VJJR
[ Parent
| on HN ]
I suspect the author was talking about defining methods for individual variants of an enum, something like
enum Foo { A, B }
impl Foo::A { fn method_on_a(&self) {} }There is an RFC[1] for making enum variants first-class types.