-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function overload calling syntax #1614
Comments
Rust doesn't have function overloads. So there's no need for a new syntax to call overloaded functions. |
struct Type;
impl Type {
fn a(_x: (), _y: ()) -> () {
}
}
impl Type {
fn a(_x: ()) -> () {
}
} Come again? |
That's "just a bug": impl Type {
fn a(_x: (), _y: ()) -> () {
}
fn a(_x: ()) -> () {
}
} errors with
|
The thing I did errors when you try to call it, but the error could be solved by adding new function call syntax that puts types into it. |
You could already create a struct Type;
trait Overload<T> {
fn a(T) -> ();
}
impl Overload<((), ())> for Type {
fn a(args: ((), ())) -> () {
}
}
impl Overload<((),)> for Type {
fn a(args: ((),)) -> () {
}
}
fn main() {
Type::a(((),));
Type::a(((),()));
} |
Filed rust-lang/rust#35763 for the overloaded function bug. |
I'm skeptical that we'll ever do overloading of this sort; so therefore I'll close this to reduce clutter. |
There should be a way to call function overloads, I propose
f::<T>::(argt)(argv)
. E.g.f::(())(())
would call a function defined asfn f(_x: ()) -> ?
when you have multiplef
with different args.The text was updated successfully, but these errors were encountered: