File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
1
11
use std:: cell:: Cell ;
2
12
3
13
struct Flag < ' a > ( & ' a Cell < bool > ) ;
4
14
5
15
impl < ' a > Drop for Flag < ' a > {
6
- fn drop ( & mut self ) {
7
- self . 0 . set ( false )
8
- }
16
+ fn drop ( & mut self ) {
17
+ self . 0 . set ( false )
18
+ }
9
19
}
10
20
11
21
fn main ( ) {
@@ -16,7 +26,7 @@ fn main() {
16
26
}
17
27
// The Flag value should be dead outside of the loop
18
28
assert_eq ! ( alive2. get( ) , false ) ;
19
-
29
+
20
30
let alive = Cell :: new ( true ) ;
21
31
for _ in std:: iter:: once ( Flag ( & alive) ) {
22
32
// The Flag value should be alive in the for loop body even if it wasn't
You can’t perform that action at this time.
0 commit comments