X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibcore%2Fcmp.rs;h=3ea4baa57b49efb1acf3de276ced9d3e1150b07d;hb=6980f82c0d152446506fee4d4a45d8afdf4ad9a4;hp=06e7e45c7014e796b125174d0a8d302b74f07b2f;hpb=30ddb5a8c1e85916da0acdc665d6a16535a12dd6;p=rust.git diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 06e7e45c701..3ea4baa57b4 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -821,10 +821,7 @@ pub trait PartialOrd: PartialEq { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn lt(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Less) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Less)) } /// This method tests less than or equal to (for `self` and `other`) and is used by the `<=` @@ -843,10 +840,7 @@ fn lt(&self, other: &Rhs) -> bool { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn le(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Less) | Some(Equal) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Less) | Some(Equal)) } /// This method tests greater than (for `self` and `other`) and is used by the `>` operator. @@ -864,10 +858,7 @@ fn le(&self, other: &Rhs) -> bool { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn gt(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Greater) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Greater)) } /// This method tests greater than or equal to (for `self` and `other`) and is used by the `>=` @@ -886,10 +877,7 @@ fn gt(&self, other: &Rhs) -> bool { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn ge(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Greater) | Some(Equal) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Greater) | Some(Equal)) } }