Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/edition/src/lib.rs')
-rw-r--r--crates/edition/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/edition/src/lib.rs b/crates/edition/src/lib.rs
index 7e9c94af40..a2269bf54d 100644
--- a/crates/edition/src/lib.rs
+++ b/crates/edition/src/lib.rs
@@ -19,6 +19,16 @@ impl Edition {
/// The current latest stable edition, note this is usually not the right choice in code.
pub const CURRENT_FIXME: Edition = Edition::Edition2021;
+ pub fn from_u32(u32: u32) -> Edition {
+ match u32 {
+ 0 => Edition::Edition2015,
+ 1 => Edition::Edition2018,
+ 2 => Edition::Edition2021,
+ 3 => Edition::Edition2024,
+ _ => panic!("invalid edition"),
+ }
+ }
+
pub fn at_least_2024(self) -> bool {
self >= Edition::Edition2024
}