mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
rephrase dangling section
This commit is contained in:
parent
14c284e6d8
commit
fbffce8a6e
@ -210,9 +210,11 @@ from under them! Multiple immutable references are okay, however.
|
|||||||
|
|
||||||
## Dangling references
|
## Dangling references
|
||||||
|
|
||||||
Rust’s references must always be valid. In other words, if we have a reference
|
In languages with pointers, it’s easy to crate a “dangling pointer” by freeing
|
||||||
to something, it must not go out of scope before the reference does. Dangling
|
some memory while keeping around a pointer to that memory. In Rust, by
|
||||||
references are a pervasive problem in languages that support them.
|
contrast, the compiler guarantees that references will never be dangling: if we
|
||||||
|
have a reference the something, the compiler will ensure that it will not go
|
||||||
|
out of scope before the reference does.
|
||||||
|
|
||||||
Let’s try to create a dangling reference:
|
Let’s try to create a dangling reference:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user