[rust-dev] Polymorphism & default parameters in rust

Stefan Plantikow Stefan.Plantikow at googlemail.com
Sat Aug 4 06:23:42 PDT 2012


Hi,

Am 02.08.2012 um 22:00 schrieb Tim Chevalier <catamorphism at gmail.com>:

> 
> You may be able to use traits and impls to overload the name a, but if
> you don't mind giving the different functions different names, this
> way doesn't require any fancy ideas.
> 

I keep wondering if we should have a way to specify a default value per type, perhaps via a specific trait that just provides a default() call (e.g. none for option).  This way optional arguments could be implemented with a simple rule: All missing arguments are replaced with calls to default() if the type implements that.

Cheers,


Stefan.





More information about the Rust-dev mailing list