3 ms·
It would be nice if subset-structs worked like they do in TypeScript, but I would still be totally happy if they had to be an exact match. Subset matching would
by brundolf 4y ago
It would be nice if subset-structs worked like they do in TypeScript, but I would still be totally happy if they had to be an exact match. Subset matching would probably be the 80% complexity for the 20% benefit
Now... a neat compromise could be something like this
fn foo<T: { bar: i32 }>(my_struct: T) {
}
foo({ bar: 12, stuff: "abc" })
That would fit a lot more smoothly into Rust's type system than the automatic subset-matching would, but even then, I'd be content without it. The most basic version of anonymous structs is hardly more than sugar over tuples, it just seems like such an easy win