From 006cf76d3bc31779b0d64a472319b55c3261bee1 Mon Sep 17 00:00:00 2001 From: Dan Shields <35669742+NukeManDan@users.noreply.github.com> Date: Mon, 15 Nov 2021 07:52:16 -0700 Subject: [PATCH] move to rust 2021, tweak macro (#428) * cargo fix --edition * move to rust 2021 * simplify macro now that patterns are supported natively Co-authored-by: James Wilson --- backend/common/Cargo.toml | 2 +- backend/telemetry_core/Cargo.toml | 2 +- backend/telemetry_shard/Cargo.toml | 2 +- backend/test_utils/Cargo.toml | 2 +- backend/test_utils/src/contains_matches.rs | 10 +++++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/common/Cargo.toml b/backend/common/Cargo.toml index 6fcb2c9..ccb03fa 100644 --- a/backend/common/Cargo.toml +++ b/backend/common/Cargo.toml @@ -2,7 +2,7 @@ name = "common" version = "0.1.0" authors = ["Parity Technologies Ltd. "] -edition = "2018" +edition = "2021" license = "GPL-3.0" [dependencies] diff --git a/backend/telemetry_core/Cargo.toml b/backend/telemetry_core/Cargo.toml index 2df969e..731b575 100644 --- a/backend/telemetry_core/Cargo.toml +++ b/backend/telemetry_core/Cargo.toml @@ -2,7 +2,7 @@ name = "telemetry_core" version = "0.1.0" authors = ["Parity Technologies Ltd. "] -edition = "2018" +edition = "2021" license = "GPL-3.0" [dependencies] diff --git a/backend/telemetry_shard/Cargo.toml b/backend/telemetry_shard/Cargo.toml index dd554ed..cce698a 100644 --- a/backend/telemetry_shard/Cargo.toml +++ b/backend/telemetry_shard/Cargo.toml @@ -2,7 +2,7 @@ name = "telemetry_shard" version = "0.1.0" authors = ["Parity Technologies Ltd. "] -edition = "2018" +edition = "2021" license = "GPL-3.0" [dependencies] diff --git a/backend/test_utils/Cargo.toml b/backend/test_utils/Cargo.toml index 2a45edb..a4d1565 100644 --- a/backend/test_utils/Cargo.toml +++ b/backend/test_utils/Cargo.toml @@ -2,7 +2,7 @@ name = "test_utils" version = "0.1.0" authors = ["James Wilson "] -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/backend/test_utils/src/contains_matches.rs b/backend/test_utils/src/contains_matches.rs index 21fa302..c707565 100644 --- a/backend/test_utils/src/contains_matches.rs +++ b/backend/test_utils/src/contains_matches.rs @@ -43,14 +43,14 @@ assert!(does_contain); */ #[macro_export] macro_rules! contains_matches { - ($expression:expr, $( $( $pattern:pat )|+ $( if $guard:expr )? ),+ $(,)?) => {{ + ($expression:expr, $( $pattern:pat $( if $guard:expr )? ),+ $(,)?) => {{ let mut items = $expression.into_iter(); // For each pattern we want to match, we consume items until // we find the first match, and then break the loop and do the // same again with the next pattern. If we run out of items, we // set the validity to false and stop trying to match. Else, we - // match againse each of the patterns and return true. + // match against each of the patterns and return true. let mut is_valid = true; $( while is_valid { @@ -63,7 +63,7 @@ macro_rules! contains_matches { }; match item { - $( $pattern )|+ $( if $guard )? => break, + $pattern $( if $guard )? => break, _ => continue } } @@ -99,10 +99,10 @@ test_utils::assert_contains_matches!( */ #[macro_export] macro_rules! assert_contains_matches { - ($expression:expr, $( $( $pattern:pat )|+ $( if $guard:expr )? ),+ $(,)?) => { + ($expression:expr, $( $pattern:pat $( if $guard:expr )? ),+ $(,)?) => { let does_contain_matches = $crate::contains_matches!( $expression, - $( $( $pattern )|+ $( if $guard )? ),+ + $( $pattern $( if $guard )? ),+ ); assert!(does_contain_matches);