Am I correct to assume that, for the following code
let a = vec![1, 2, 3];
let b = &a;
let c = b;
The memory presentation will be something like this, assuming the value of b
is "B"?
_ _
b|B| c|B|
|____________|
|
V
_________
a|_________|
I'm only asking about immutable references, as there can be only 1 mutable reference, as far as I remember.
n. A copy of a record kept for easy access to the information it contains, as opposed to its intrinsic or evidential value. A copy of a record distributed to make recipients aware of the content but not directing the recipient to take any action on the matter.
A String is a type that does not implement the Copy trait.
You can just use . clone() for your duplicate function.
Yes, this is correct.
In Rust terms, &T
is Copy
, which means that it can be copied bitwise without transferring ownership.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With