From ebf3dc334a0d671abd3a41d9e931350abf2fb17a Mon Sep 17 00:00:00 2001 From: Stephane Raux Date: Sun, 28 Jan 2018 18:59:55 -0800 Subject: [PATCH 1/2] Fixed doc regarding Drop and static Types implementing `Drop` are allowed in `static` and `const` definitions since rust 1.22.0. --- first-edition/src/const-and-static.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/first-edition/src/const-and-static.md b/first-edition/src/const-and-static.md index 66a48566bd..b7f3a49d78 100644 --- a/first-edition/src/const-and-static.md +++ b/first-edition/src/const-and-static.md @@ -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 From 1034a3477b16537a0a6831a3967a0f8247423d14 Mon Sep 17 00:00:00 2001 From: Stephane Raux Date: Sun, 28 Jan 2018 19:43:27 -0800 Subject: [PATCH 2/2] Fixed statement about static and Sync --- first-edition/src/const-and-static.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/first-edition/src/const-and-static.md b/first-edition/src/const-and-static.md index b7f3a49d78..e50a21367b 100644 --- a/first-edition/src/const-and-static.md +++ b/first-edition/src/const-and-static.md @@ -38,6 +38,9 @@ reference stored in a static has a [`'static` lifetime][lifetimes]: static NAME: &'static str = "Steve"; ``` +The type of a `static` value must be `Sync` unless the `static` value is +mutable. + [lifetimes]: lifetimes.html ## Mutability @@ -64,8 +67,6 @@ unsafe { [unsafe]: unsafe.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