Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think if one implemented linear types in Rust they could still be forgotten, but not. Basically you would have constraints like:

* creating type &T or &mut T is forbidden; therefore also applying & and &mut to a value of linear type, or using ref and ref mut at the top level of patterns that match a value with linear type

* field access is forbidden, except through pattern matching (either match or let) because pattern matching consumes the matched value

* implementing Copy or Drop is not allowed (Copy makes no sense, with Drop using destructuring patterns would not be possible). Well, Drop would not be implementable anyway, together with many other traits, because it takes &mut self (which is not creatable).

I would have no idea how to express it in the syntax.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: