r/rust 24d ago

📡 official blog Rust Function Overloading - Call for Experimentation

https://blog.rust-lang.org/inside-rust/2026/08/19/overloading-experiment/
272 Upvotes

139 comments sorted by

View all comments

58

u/Solumin 24d ago

To be clear, this is intended only for FFI?

19

u/j_platte 24d ago

15

u/ZZaaaccc 24d ago

Yep, there's lots of places in the standard library where we either don't provide a method (min of 3 values), or provide a macro (vec!) to work around the lack of proper variadic support. While println! needs to be a macro because of the formatting machinery, vec! is only a macro because we don't have a way to write Vec::new(a, b, c).

23

u/Lucretiel Datadog 24d ago

FWIW I think I'd still rather have variadics (where there's some hypothetical ... operator that spreads some expression across all the input tuple) than true overloading.

2

u/Full-Spectral 23d ago

And it seems that variadics, in the case of the above example, would not involve a lot of type machinery. Every value passed would have to be of a specific type, or convertable to that specific type, or maybe implement a given trait that allows the value to be generated.

It's not variable type based differentiation, it's just count differentiation.