Version: 1.1.0
Ownership
Argument conventions say whether a function borrows a value or takes it. The default is the safest one that still reads naturally.
Essentials
readborrows immutably. The caller keeps the value.mutborrows and allows changes. Only one mutable borrow is active.ownedtakes the value. The caller must transfer it.varin a struct field means the struct owns that field.- Conventions are checked at compile time, so use-after-move is an error.
Example
fn show(read text: String):
print(text)
fn rewrite(mut text: String):
text += "!"
Keep in mind
Start with the defaults. Add mut or owned only when the function's job is to change or consume the value.