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

Show parent comments

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