Borrowing ( & )
Accessing data without transferring ownership.
Syntax
fn name(x: &String) { }Description
You BORROW a value with &; ownership is not moved, and it can continue to be used. A way to pass large data to functions without copying.
Example
Loading editor…
Expected output
5 Hello
When to use?
Passing data to a function without copying.