pedant_core/resolution/rust/
edition.rs1use std::fmt;
4
5#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum CargoEdition {
8 #[default]
10 Rust2015,
11 Rust2018,
13 Rust2021,
15 Rust2024,
17}
18
19impl CargoEdition {
20 pub(super) fn parse(text: &str) -> Option<Self> {
21 match text {
22 "2015" => Some(Self::Rust2015),
23 "2018" => Some(Self::Rust2018),
24 "2021" => Some(Self::Rust2021),
25 "2024" => Some(Self::Rust2024),
26 _ => None,
27 }
28 }
29
30 pub(in crate::resolution::rust) fn permits_bare_callable_traits(self) -> bool {
31 matches!(self, Self::Rust2015 | Self::Rust2018)
32 }
33}
34
35impl fmt::Display for CargoEdition {
36 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
37 let text = match self {
38 Self::Rust2015 => "2015",
39 Self::Rust2018 => "2018",
40 Self::Rust2021 => "2021",
41 Self::Rust2024 => "2024",
42 };
43 formatter.write_str(text)
44 }
45}