Skip to content

Commit

Permalink
#[derive(Default)] on enums, bump MSRV to 1.62
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Jan 19, 2023
1 parent 43862d2 commit c45264c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
strategy:
matrix:
rust:
- { version: "1.61.0", name: MSRV }
- { version: "1.62.0", name: MSRV }
- { version: stable, name: stable }
kind:
- name: no_std
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
strategy:
matrix:
rust:
- { version: "1.61.0", name: MSRV }
- { version: "1.62.0", name: MSRV }
- { version: stable, name: stable }
os:
- { name: Ubuntu, value: ubuntu-20.04 }
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/powerset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
strategy:
matrix:
rust:
- { version: "1.61.0", name: MSRV }
- { version: "1.62.0", name: MSRV }
- { version: stable, name: stable }
kind:
- name: no_std
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# time

[![minimum rustc: 1.61](https://img.shields.io/badge/minimum%20rustc-1.61-yellowgreen?logo=rust&style=flat-square)](https://www.whatrustisit.com)
[![minimum rustc: 1.62](https://img.shields.io/badge/minimum%20rustc-1.62-yellowgreen?logo=rust&style=flat-square)](https://www.whatrustisit.com)
[![version](https://img.shields.io/crates/v/time?color=blue&logo=rust&style=flat-square)](https://crates.io/crates/time)
[![build status](https://img.shields.io/github/actions/workflow/status/time-rs/time/build.yaml?branch=main&style=flat-square)](https://github.com/time-rs/time/actions)
[![codecov](https://codecov.io/gh/time-rs/time/branch/main/graph/badge.svg?token=yt4XSmQNKQ)](https://codecov.io/gh/time-rs/time)
Expand Down
2 changes: 1 addition & 1 deletion time-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "time-core"
version = "0.1.0"
authors = ["Jacob Pratt <[email protected]>", "Time contributors"]
edition = "2021"
rust-version = "1.60.0"
rust-version = "1.62.0"
repository = "https://github.com/time-rs/time"
keywords = ["date", "time", "calendar", "duration"]
categories = ["date-and-time"]
Expand Down
2 changes: 1 addition & 1 deletion time-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "time-macros"
version = "0.2.6"
authors = ["Jacob Pratt <[email protected]>", "Time contributors"]
edition = "2021"
rust-version = "1.61.0"
rust-version = "1.62.0"
repository = "https://github.com/time-rs/time"
keywords = ["date", "time", "calendar", "duration"]
categories = ["date-and-time"]
Expand Down
18 changes: 2 additions & 16 deletions time-macros/src/format_description/format_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,6 @@ macro_rules! target_value {
};
}

macro_rules! derived_default_on_enum {
($type:ty; $default:expr) => {};
($attr:meta $type:ty; $default:expr) => {
impl Default for $type {
fn default() -> Self {
$default
}
}
};
}

macro_rules! modifier {
($(
enum $name:ident $(($target_ty:ty))? {
Expand All @@ -269,14 +258,11 @@ macro_rules! modifier {
),* $(,)?
}
)+) => {$(
#[derive(Default)]
enum $name {
$($variant),*
$($(#[$attr])? $variant),*
}

$(derived_default_on_enum! {
$($attr)? $name; $name::$variant
})*

impl $name {
/// Parse the modifier from its string representation.
fn from_modifier_value(value: &Spanned<&[u8]>) -> Result<Option<Self>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "time"
version = "0.3.17"
authors = ["Jacob Pratt <[email protected]>", "Time contributors"]
edition = "2021"
rust-version = "1.60.0"
rust-version = "1.62.0"
repository = "https://github.com/time-rs/time"
homepage = "https://time-rs.github.io"
keywords = ["date", "time", "calendar", "duration"]
Expand Down
20 changes: 2 additions & 18 deletions time/src/format_description/parse/format_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,6 @@ macro_rules! target_value {
};
}

// TODO use `#[derive(Default)]` on enums once MSRV is 1.62 (NET 2022-12-30)
/// Simulate `#[derive(Default)]` on enums.
macro_rules! derived_default_on_enum {
($type:ty; $default:expr) => {};
($attr:meta $type:ty; $default:expr) => {
impl Default for $type {
fn default() -> Self {
$default
}
}
};
}

/// Declare the various modifiers.
///
/// For the general case, ordinary syntax can be used. Note that you _must_ declare a default
Expand All @@ -350,14 +337,11 @@ macro_rules! modifier {
),* $(,)?
}
)+) => {$(
#[derive(Default)]
enum $name {
$($variant),*
$($(#[$attr])? $variant),*
}

$(derived_default_on_enum! {
$($attr)? $name; $name::$variant
})*

impl $name {
/// Parse the modifier from its string representation.
fn from_modifier_value(value: &Spanned<&[u8]>) -> Result<Option<Self>, Error> {
Expand Down

0 comments on commit c45264c

Please sign in to comment.