-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
luk6xff.github.io/content/other/safe_secure_rust_book/src/intro/safety_features_overview.md
Lines 34 to 46 in 857d4fa
| ### 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels