The Rust book states:
Each value in Rust has an owner
It does not explain what type of entity this owner is. Is it a programmer? a variable? A statement? A code block?
What is the precise definition of what type of entity can be a 'value owner'?
Usually, owners are variables or fields; they are responsible for dropping the value owned. However, more surprisingly, even the program binary can be an owner too. As an example, that's the case for string literals:
let s = "Hello World";
The string literal above is stored in the program binary itself, s is just a reference to it. As such, its lifetime is 'static, i.e., the literal lifespan corresponds to the program execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With