On 2014-04-04, at 12:30, Vadim Chugunov <[email protected]> wrote: > trait Invalid { > fn invalid() -> Self; > } > The compiler could then perform option space optimization for any type > implementing 'Invalid'.
I just realized that Rust already uses static methods just like the one you suggested for defining values that should be compile-time constants. For example std::num::Zero requires a static method 'zero' which should always return the same value. I do think that a more robust language design would be to force those things to be compile-time constants rather than just specifying in the documentation that they should return one.
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
