by necubi · 6y ago · 0 comments
Affine types in Rust are anything with move semantics; for example you can create a method that consumes itself like this:
impl A {
fn use(&mut self) {
// takes a mutable reference to self, so it
// can be used again later
}
fn consume(self) {
// moves self into this function, which means
// it cannot be used again
}
}Obviously it's not part of the type system itself, but doesn't the must_use attr get pretty close?