3 ms·
What's the importance of having to use a value? I.e. isn't this the same as discarding it? Or is related to things like resource finalizers — i.e. once you open
by atombender 6y ago
What's the importance of having to use a value? I.e. isn't this the same as discarding it? Or is related to things like resource finalizers — i.e. once you open a file, you have to "consume" it in order for it to be closed?
- necubi 6y agoThere are lots of bugs that linear types can prevent. For example, if you have an operation that returns a Result that must be handled, you can use linear types to ensure that it is. You can also use linear types to implement safe memory management (Rust's lifetime system is basically a special case of this), by returning a value from `malloc` which must be used in a call to `free`.
- unnah 6y agoUsually what happens in Rust is that if you don't use an owned allocation, it is automatically freed. However, it is possible to leak memory by making a cycle of heap-allocated structures. Can such cycles be prevented by linear types?