@@ -23,11 +23,20 @@ pub enum Edition {
23
23
Edition2021 ,
24
24
/// The 2024 edition
25
25
Edition2024 ,
26
+ /// The next edition - this variant will always exist and features associated with next will be
27
+ /// moved to the next 20XX edition when it is established. This allows edition changes to
28
+ /// be implemented before the next edition is planned.
29
+ EditionNext ,
26
30
}
27
31
28
32
// Must be in order from oldest to newest.
29
- pub const ALL_EDITIONS : & [ Edition ] =
30
- & [ Edition :: Edition2015 , Edition :: Edition2018 , Edition :: Edition2021 , Edition :: Edition2024 ] ;
33
+ pub const ALL_EDITIONS : & [ Edition ] = & [
34
+ Edition :: Edition2015 ,
35
+ Edition :: Edition2018 ,
36
+ Edition :: Edition2021 ,
37
+ Edition :: Edition2024 ,
38
+ Edition :: EditionNext ,
39
+ ] ;
31
40
32
41
pub const EDITION_NAME_LIST : & str = "2015|2018|2021|2024" ;
33
42
@@ -42,6 +51,7 @@ impl fmt::Display for Edition {
42
51
Edition :: Edition2018 => "2018" ,
43
52
Edition :: Edition2021 => "2021" ,
44
53
Edition :: Edition2024 => "2024" ,
54
+ Edition :: EditionNext => "next" ,
45
55
} ;
46
56
write ! ( f, "{s}" )
47
57
}
@@ -54,6 +64,7 @@ impl Edition {
54
64
Edition :: Edition2018 => "rust_2018_compatibility" ,
55
65
Edition :: Edition2021 => "rust_2021_compatibility" ,
56
66
Edition :: Edition2024 => "rust_2024_compatibility" ,
67
+ Edition :: EditionNext => "edition_next_compatibility" ,
57
68
}
58
69
}
59
70
@@ -63,6 +74,7 @@ impl Edition {
63
74
Edition :: Edition2018 => true ,
64
75
Edition :: Edition2021 => true ,
65
76
Edition :: Edition2024 => true ,
77
+ Edition :: EditionNext => false ,
66
78
}
67
79
}
68
80
@@ -85,6 +97,11 @@ impl Edition {
85
97
pub fn at_least_rust_2024 ( self ) -> bool {
86
98
self >= Edition :: Edition2024
87
99
}
100
+
101
+ /// Are we allowed to use features from the next edition?
102
+ pub fn at_least_edition_next ( self ) -> bool {
103
+ self >= Edition :: EditionNext
104
+ }
88
105
}
89
106
90
107
impl FromStr for Edition {
@@ -95,6 +112,7 @@ impl FromStr for Edition {
95
112
"2018" => Ok ( Edition :: Edition2018 ) ,
96
113
"2021" => Ok ( Edition :: Edition2021 ) ,
97
114
"2024" => Ok ( Edition :: Edition2024 ) ,
115
+ "next" => Ok ( Edition :: EditionNext ) ,
98
116
_ => Err ( ( ) ) ,
99
117
}
100
118
}
0 commit comments