5 ms·
It is correct. For example, this code (admittedly a contrived example, just to illustrate the point) compiles in 1.82 but not in 1.83: trait OptionExt {
by School-Cotton 2y ago
It is correct. For example, this code (admittedly a contrived example, just to illustrate the point) compiles in 1.82 but not in 1.83:
trait OptionExt {
fn get_or_insert_default();
}
impl<T> OptionExt for Option<T> {
fn get_or_insert_default() {}
}
fn main() {
Option::<()>::get_or_insert_default();
}
The reason is that `get_or_insert_default` was added to the stdlib in 1.83, and takes a different number of arguments, so it clashes with the user-defined one here.
- 0x457 2y agoInteresting, I would think that having OptionExt in scope would make it clear which method to use.