mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 23:38:41 +08:00
'from' and 'to' are problematic with references, try to avoid :-/
I would actually say "reference to s1" here, but I think this is trying to say "create a reference out of s1" but that sounds like you don't have s1 anymore since you turned it into something else and urgh am I overthinking this?
This commit is contained in:
parent
23d4435073
commit
c2c744b4a5
@ -62,8 +62,8 @@ let s1 = String::from("hello");
|
||||
let len = calculate_length(&s1);
|
||||
```
|
||||
|
||||
The `&s1` syntax lets us create a reference from `s1`. This reference _refers_
|
||||
to the value of `s1`, but does not own it. Because it does not own it, the
|
||||
The `&s1` syntax lets us create a reference with `s1`. This reference _refers_
|
||||
to the value of `s1` but does not own it. Because it does not own it, the
|
||||
value it points to will not be dropped when the reference goes out of scope.
|
||||
|
||||
Likewise, the signature of the function uses `&` to indicate that it takes
|
||||
|
Loading…
Reference in New Issue
Block a user