In Rust, a struct can have a method that takes ownership of the struct and moves it, making it illegal to use the struct again later, e.g.
struct Foo {}
impl Foo {
fn consume(self) {
println!("consumed!");
}
}
fn main() {
let x = Foo {};
x.consume();
x.consume(); // WON'T COMPILE
}
Are there any clever ways to represent a similar state change using TypeScript’s type system?