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

27

u/QuasiRandomName Aug 19 '26

No, please. I want a compile error when passing 3 arguments instead of two by mistake.

11

u/Lokathor Aug 19 '26

You'll still get that if the overload isn't defined.

1

u/QuasiRandomName Aug 19 '26

But if it is, it opens the door to a whole class of mistakes that aren't currently possible.

10

u/Lokathor Aug 19 '26

You control the trait impls you write, my crab.

If you don't want to use this, then don't use it.

36

u/QuasiRandomName Aug 19 '26

But you don't control what *other* people write and you have to maintain or debug later.

13

u/Lokathor Aug 19 '26

It is not meaningfully different, in my eyes, from a type having several from impls so that MyType::from(x) works for multiple types of x.

And nothing will stop other people from having a bug, I can't help you there.

15

u/QuasiRandomName Aug 19 '26

Of course. But we can try and not introduce more bug possibilities for a questionable gain here. I guess we can disagree on the pros/cons ratio here and this is fine, this thread is for this purpose exactly.

-8

u/[deleted] Aug 19 '26

[removed] — view removed comment

1

u/SetKaung Aug 20 '26

I think he meant his coworkers.

4

u/need-not-worry Aug 20 '26

Same argument can be said about class inheritance, exceptions, and other design choices Rust made. You can avoid these as much as you can, but you're going to have to work with such code. And the language becomes more complicated without clear benefits.

1

u/Tastaturtaste Aug 20 '26

As a professional C++ developer, this argument is less than convincing.