File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 3
3
The following is a summary of changes that only apply to code compiled with
4
4
the 2018 edition compared to the 2015 edition.
5
5
6
- - [ Non-lexical lifetimes]   ; (future inclusion planned for 2015 edition)
7
6
- [ At most once] ` ? ` macro repetition operator.
8
7
- [ Path changes] :
9
8
- Paths in ` use ` declarations work the same as other paths.
Original file line number Diff line number Diff line change 1
1
# Non-lexical lifetimes
2
2
3
- ![ Minimum Rust version: 1.31] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.31-brightgreen.svg )
3
+ ![ Minimum Rust version: 1.31] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.31-brightgreen.svg ) for 2018 edition
4
+
5
+ ![ Minimum Rust version: 1.36] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.36-brightgreen.svg ) for 2015 edition
4
6
5
7
The borrow checker has been enhanced to accept more code, via a mechanism
6
8
called "non-lexical lifetimes." Consider this example:
@@ -44,7 +46,7 @@ fn main() {
44
46
let mut x = 5;
45
47
let y = &x;
46
48
let z = &mut x;
47
-
49
+
48
50
println!("y: {}", y);
49
51
}
50
52
```
@@ -74,7 +76,7 @@ error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immuta
74
76
| -- immutable borrow occurs here
75
77
5 | let z = &mut x;
76
78
| ^^^^^^ mutable borrow occurs here
77
- 6 |
79
+ 6 |
78
80
7 | println!("y: {}", y);
79
81
| - borrow later used here
80
82
```
You can’t perform that action at this time.
0 commit comments