Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made edition an enum again #185

Merged
merged 5 commits into from
Jul 1, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 23 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
use std::fmt;
use std::hash::Hash;
use std::path::PathBuf;
use std::process::Command;
use std::str::from_utf8;
Expand Down Expand Up @@ -452,29 +453,28 @@ pub struct Target {
}

/// The Rust edition
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(transparent)]
pub struct Edition(pub Cow<'static, str>);

impl Edition {
/// Creates a new `Edition`.
pub fn new(edition: impl Into<Cow<'static, str>>) -> Self {
Self(edition.into())
}

/// Creates a new `Edition` from a static string.
pub const fn new_const(edition: &'static str) -> Self {
Self(Cow::Borrowed(edition))
}

/// Edition 2015.
pub const E2015: Self = Self::new_const("2015");

/// Edition 2018.
pub const E2018: Self = Self::new_const("2018");

/// Edition 2021.
pub const E2021: Self = Self::new_const("2021");
///
/// As of writing this comment rust editions 2024, 2027 and 2030 are not actually a thing yet but are here nonetheless for future proofing.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Edition {
/// Edition 2015
#[serde(rename = "2015")]
E2015,
/// Edition 2018
#[serde(rename = "2018")]
E2018,
/// Edition 2021
#[serde(rename = "2021")]
E2021,
/// Edition 2024
#[serde(rename = "2024")]
morr0ne marked this conversation as resolved.
Show resolved Hide resolved
E2024,
/// Edition 2027
#[serde(rename = "2027")]
E2027,
/// Edition 2030
#[serde(rename = "2030")]
E2030,
}

impl Default for Edition {
Expand Down