Why Rust doesn't have function overloading?

Yeah, that probably would've worked with type inference. Like most features that other languages have and Rust doesn't, it was discussed before:

According to the triage report, it was uneventfully postponed.

I suppose the main reason it never happened, at least based on searching the old ML archives for mentions of the word "overload", is just lack of demand. I can't find anyone beyond this RFC that's asking for arity-based overloading, compared to the way there's always someone expressing a desire for full-blown function overloading every couple years.

Sure, arity-based overload would be easier to add than arbitrary type overloading, but it still requires some design work, and it doesn't solve as many problems as arbitrary type overloading.

The main language I know of that has arity-based overloading is Erlang, and it has pattern matching in function signatures to simulate type-driven overloading.

3 Likes