[rust-dev] Functions overloading

Alexander Stavonin a.stavonin at gmail.com
Thu Apr 12 01:08:21 PDT 2012


What's about function overloading? Something like this:

fn foo(val: int) {
    io::println("int");
}

fn foo(val: str) {
    io::println("str");
}

fn main() {
    foo(1);
    foo("test");
}

But :(

main.rs:3:0: 5:1 error: duplicate definition of foo
main.rs:3 fn foo(val: int) {
main.rs:4     io::println("int");
main.rs:5 }

As I understood, similar code can be implemented by using ifase and impl, but it's very cumbersome way.


More information about the Rust-dev mailing list