Skip to content

Rust Safety Features > Example: Ownership 2 > Description doesn't match code example. #9

@etam

Description

@etam

### Example: Ownership 2
```rust,editable
fn greet(name: String) {
println!("Hello {name}")
}
fn main() {
let name = String::from("Tom");
greet(name);
// greet(name);
}
```
In this example, the ownership of the string `a` is moved to `b`. Attempting to use `a` after this point results in a compile-time error, preventing use-after-move bugs.

The explanation under code example talks about variables "a" and "b", but the example has only "name" variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions