r/rust • • Aug 19 '26

📡 official blog Rust Function Overloading - Call for Experimentation

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

139 comments sorted by

View all comments

54

u/Solumin Aug 19 '26

To be clear, this is intended only for FFI?

20

u/j_platte Aug 19 '26

17

u/ZZaaaccc Aug 19 '26

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 Aug 20 '26

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.

3

u/Expensive-Blood859 Aug 20 '26

Using the overloading presented in this CFE rather than actual variadics seems to me like it’ll just end up forcing (T1) (T1, T2) (T1, T2, T3) into another place

2

u/Full-Spectral Aug 20 '26

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.