3
lorentz
2y

Hey guys, did you know that you can use `impl Trait` in the position of an argument in Rust to identify an argument with its capabilities without the boilerplate of a generic parameter?

With that in mind, I present to you Rust's universal type:

Comments
  • 0
    You can't even create a non-jargon alias for it because aliases don't support existential types.
  • 0
    Yeah, that is what interfaces are there for. They just happen to be called traits in Rust...
  • 2
    @Oktokolo The ability to do this isn't new, only previously this required a generic which meant that the trait bounds were defined separately from the sole variable they were applied to.

    Anyway the feature isn't new either, I'm just ranting about how it adds even more jargon in an already very divergent language.
  • 1
    Wait I dont get it
    Youre just using a generic/template with a constraint on the type, right? Thats how I understand rust handles it.
    Or using dyn you have runtime checking, similar to virtual+inheritance in C++ I guess.
  • 0
    @lorentz Literally the most needless flaw of Rust is that it renames well-known things for no fuckin purpose other than to make it harder for devs to get into Rust. Elitism and ego are everywhere i guess.
Add Comment