The terms "values" and "owners" in the tutorials

⚓ Rust    📅 2025-10-07    👤 surdeus    👁️ 5      

surdeus

For nearly two years I am now struggling with the popular Rust phrase

Each value in Rust has an owner.

which occurs in the official tutorial, and in many beginner tutorials and books, typically without a more detailed explanation.

The obvious question for a reader should be: Who is the owner of these "values"? I think typically the owners are variables, or when values are moved into functions or closures, the ownership transfers to the parameters. For string slices and array literals, the owner should be the data segment of the executable binary? Are there more types of possible owners?

And the other issue is: What is a value, and has each value in Rust really an owner? What is with

let a = 1 + 2;

or expressions like

if a > 3 * 4 {

Are the literals 1, 2, 3, 4 values, and have they owners? Have numeric or character constants owners?

Can and should we define what values in Rust actually mean, and should we use the distinction of l- and r-values sometimes uses for other languages?

References: What is Ownership? - The Rust Programming Language

5 posts - 3 participants

Read full topic

🏷️ Rust_feed