From 641b0e078d44428d1d833510d4264f04d20fbb11 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 28 Apr 2021 17:34:37 +0200 Subject: [PATCH 1/3] Remove unneeded `Ord` bound from All --- frame/support/src/traits/members.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/traits/members.rs b/frame/support/src/traits/members.rs index 125f096fa92e1..d9dca4b7713d1 100644 --- a/frame/support/src/traits/members.rs +++ b/frame/support/src/traits/members.rs @@ -27,7 +27,7 @@ pub trait Contains { /// A `Contains` implementation which always returns `true`. pub struct All(PhantomData); -impl Contains for All { +impl Contains for All { fn contains(_: &T) -> bool { true } } From 4453bba9bce8ffadd9b6624b8a30c42ef068f483 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 28 Apr 2021 17:35:35 +0200 Subject: [PATCH 2/3] Fixes --- frame/support/src/traits/members.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/traits/members.rs b/frame/support/src/traits/members.rs index d9dca4b7713d1..871a603ff8708 100644 --- a/frame/support/src/traits/members.rs +++ b/frame/support/src/traits/members.rs @@ -27,7 +27,7 @@ pub trait Contains { /// A `Contains` implementation which always returns `true`. pub struct All(PhantomData); -impl Contains for All { +impl Contains for All { fn contains(_: &T) -> bool { true } } From 45fc47790bd1010ff3f84ecdc79208ead028dc7e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 28 Apr 2021 17:47:24 +0200 Subject: [PATCH 3/3] Contains supports tuples --- frame/support/src/traits/members.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frame/support/src/traits/members.rs b/frame/support/src/traits/members.rs index 871a603ff8708..8b9c2c90f541d 100644 --- a/frame/support/src/traits/members.rs +++ b/frame/support/src/traits/members.rs @@ -31,6 +31,16 @@ impl Contains for All { fn contains(_: &T) -> bool { true } } +#[impl_trait_for_tuples::impl_for_tuples(30)] +impl Contains for Tuple { + fn contains(t: &T) -> bool { + for_tuples!( #( + if Tuple::contains(t) { return true } + )* ); + false + } +} + /// Create a type which implements the `Contains` trait for a particular type with syntax similar /// to `matches!`. #[macro_export]