mirror of https://github.com/rust-lang/book
Fixed doc regarding Drop and static
Types implementing `Drop` are allowed in `static` and `const` definitions since rust 1.22.0.
This commit is contained in:
parent
df18aec936
commit
ebf3dc334a
|
@ -64,10 +64,7 @@ unsafe {
|
|||
|
||||
[unsafe]: unsafe.html
|
||||
|
||||
Furthermore, any type stored in a `static` must be `Sync`, and must not have
|
||||
a [`Drop`][drop] implementation.
|
||||
|
||||
[drop]: drop.html
|
||||
Furthermore, any type stored in a `static` must be `Sync`.
|
||||
|
||||
# Initializing
|
||||
|
||||
|
@ -75,6 +72,14 @@ Both `const` and `static` have requirements for giving them a value. They must
|
|||
be given a value that’s a constant expression. In other words, you cannot use
|
||||
the result of a function call or anything similarly complex or at runtime.
|
||||
|
||||
# Dropping
|
||||
|
||||
Types implementing [`Drop`][drop] are allowed in `const` and `static`
|
||||
definitions. Constants are inlined where they are used and are dropped
|
||||
accordingly. `static` values are not dropped.
|
||||
|
||||
[drop]: drop.html
|
||||
|
||||
# Which construct should I use?
|
||||
|
||||
Almost always, if you can choose between the two, choose `const`. It’s pretty
|
||||
|
|
Loading…
Reference in New Issue