Skip to content

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

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.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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