On 29/05/14 08:52 PM, Tommi wrote:
> On 2014-05-30, at 3:42, Eric Reed <[email protected]> wrote:
> 
>> Rust *does* have function overloading. That's *exactly* what traits are for.
>> If you want to overload a function, then make it a trait and impl the trait 
>> for all the types you want to overload it with.
> 
> I've been trying to figure out how exactly to do this. How would I write a 
> function that's overloaded based on whether its argument's type implements 
> Iterator or RandomAccessIterator?

Maybe by implementing the function in a trait as a default method and
doing an override for types implementing RandomAccessIterator.

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to