Skip to content

Commit

Permalink
Fixed doc regarding Drop and static
Browse files Browse the repository at this point in the history
Types implementing `Drop` are allowed in `static` and `const` definitions since
rust 1.22.0.
  • Loading branch information
stephaneyfx committed Jan 29, 2018
1 parent df18aec commit ebf3dc3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions first-edition/src/const-and-static.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,22 @@ 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

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
Expand Down

0 comments on commit ebf3dc3

Please sign in to comment.