Pre-RFC: `=` for struct construction

That should already work with the current syntax though, shouldn't it? Isn't let s = MyStruct { a: 42: u64 }; already unambiguous to parse? Field name, colon, then an expression, where the expression can contain an optional type ascription.

And while we are at consistency — another problem with this proposal is this: will it change struct patterns too? If so, will it change them to MyStruct { name = value } as well? Because that doesn't make sense at all:

match foo {
    Foo { name = 1337 } => …,
}

This looks like the field is being assigned the value 1337 in the pattern, whereas it's not, it's a comparison. That's downright confusing.

1 Like