On 4/18/12 4:26 PM, Alexander Stavonin wrote:
Stefan, I understood you idea but I have problem with compilation.

fn_overloading.rs:31:34: 31:80 error: method `to_input` has an incompatible type: type parameter vs int fn_overloading.rs:31 <http://fn_overloading.rs:31> impl <t> of to_input<t> for int { fn to_input() -> input<int> { ret val(self); } } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think you wanted:

impl of to_input<int> for int { fn to_input() -> input<int> { ret val(self); } }

Actually, we should probably not allow free variables like that which are unbound in the iface type. I am not sure what problem it can cause but I have distant memory of unsoundness that results from such things when combined with existential types... have to go refresh my memory.

Also, am I right that in this case we could not make overloading for different types, for example for str and int?

You could add to the enum and thus support overloading for as many types as you like.


Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to