Pre-pre-RFC: syntactic sugar for `Default::default()`

Why not just go all the way then

#[allow(non_upper_case_globals)]
static Foo: FooConstructor = FooConstructor;
#[derive(Copy, Clone)]
struct FooConstructor;

impl FnOnce<(i32, i32, RangeFull)> for FooConstructor {
    type Output = Foo;
    extern "rust-call" fn call_once(self, (_0, _1, ..): (i32, i32, RangeFull)) -> Foo {
        Foo { _0, _1, _2: 4, _3: 5 }
    }
}

impl FnOnce<(i32, i32, i32, RangeFull)> for FooConstructor {
    type Output = Foo;
    extern "rust-call" fn call_once(self, (_0, _1, _2, ..): (i32, i32, i32, RangeFull)) -> Foo {
        Foo { _0, _1, _2, _3: 5 }
    }
}

impl FnOnce<(i32, i32, i32, i32)> for FooConstructor {
    type Output = Foo;
    extern "rust-call" fn call_once(self, (_0, _1, _2, _3): (i32, i32, i32, i32)) -> Foo {
        Foo { _0, _1, _2, _3 }
    }
}

fn main() {
    dbg!(Foo(0, 1, ..));
    dbg!(Foo(0, 1, 2, ..));
    dbg!(Foo(0, 1, 2, 3));
}
1 Like