What if we made Rust more like Java?
-
What if we made Rust more like Java?
https://theincredibleholk.org/blog/2024/08/26/anonymous-impls/
-
@theincredibleholk I dig a lot of this! I have to admit I didn’t realize this is what you meant by anonymous impl though, but impl as an expression seems organic to me.
(I thought up meant anonymous as in I could constrain one side of my interface without distributing the trait, sort of a golang style approach)
-
@ironchamber I will admit, anonymous impls is kind of a jargony term. I wonder if something like "expression impls" or "impl expressions" would be a better name for them?
-
@theincredibleholk Huh, interesting. Even this ends up looking like a weird workaround for trait implementations being another layer of nominal typing rather than structural a la TS interfaces or Swift protocols, at first blush. Also, I don’t think I have ever been tempted to do it this way rather than just declaring a struct and implementing whatever method on it… but now I cannot un-see this and there are multiple places I do things where that high ceremony original could be handy.