Off the top of my head, this seems like a great idea that is much less a hack than turbofish is .
Does the mixing with struct patterns cause ambiguity, or is it just a matter of unreadable code?
let Foo { x : u32 } = Foo { x : 1 };
This doesn’t seem so bad? To me, it is the right hand side which is weird and should have been Foo { x = 1 }. Or is there something else you had in mind being the problem?
Also, there's no ambiguity in struct patterns, only confusion. field in Struct { field } is NOT a pattern, so type ascription is not applicable to it.
The syntax is either Struct { ident: PAT } (in this case there's a pattern and this pattern can use type ascription) or Struct { ident } (in this case there's no pattern syntactically, so there can be no type ascription).
Indeed. I was entirely taken aback by this. I wasn't aware that you could do this.
So... doesn't types in pattern become ambiguous (for structs with named fields..) / constitute a breaking change?
let Foo { x : u32 } = y binds the field y.x to the variable u32 (not the type).
It looks like it is type ascription, but it is not.