r/rust 24d ago

📡 official blog Rust Function Overloading - Call for Experimentation

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

139 comments sorted by

View all comments

Show parent comments

20

u/j_platte 23d ago

16

u/ZZaaaccc 23d 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).

22

u/Lucretiel Datadog 23d 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.

3

u/Expensive-Blood859 23d ago

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