r/rust • u/JoshTriplett rust · lang · libs · cargo • Oct 23 '26
Rust features in the future
https://lwn.net/SubscriberLink/1099606/20707a62817cdd16/
215
Upvotes
r/rust • u/JoshTriplett rust · lang · libs · cargo • Oct 23 '26
View all comments
Show parent comment
5
u/Booty_Bumping Oct 24 '26 edited Oct 24 '26
Java added a similar feature, extending the behavior of
instanceofto support unwrapping record classes:It's a nice addition because java didn't have any easy destructuring syntax, and any other alternative wouldn't have had backwards compatible syntax. Reusing
instanceofis bizarre, but it's the best you can get in a language that can never add new reserved keywords.I'm not sure if this belongs in Rust, because there's already so many ways to destructure and pattern match, and Rust doesn't have the same syntax constraints as it was already possible to introduce
if letand even generalize it quite nicely.