Remove unneeded Ord bound from All, Contains supports tuples (#8691)

* Remove unneeded `Ord` bound from All

* Fixes

* Contains supports tuples
This commit is contained in:
Gavin Wood
2021-04-28 18:25:00 +02:00
committed by GitHub
parent a7facf25e4
commit 0d65a936d2
+11 -1
View File
@@ -27,10 +27,20 @@ pub trait Contains<T> {
/// A `Contains` implementation which always returns `true`.
pub struct All<T>(PhantomData<T>);
impl<T: Ord> Contains<T> for All<T> {
impl<T> Contains<T> for All<T> {
fn contains(_: &T) -> bool { true }
}
#[impl_trait_for_tuples::impl_for_tuples(30)]
impl<T> Contains<T> 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]