From 8bc33cfd4494955690f48ef8cdd2d5193b7a0ff4 Mon Sep 17 00:00:00 2001 From: Sunli Date: Mon, 4 Jan 2021 08:18:28 +0800 Subject: [PATCH] Clippy clean --- parser/src/parse/utils.rs | 4 ++-- src/registry/mod.rs | 28 +++++----------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/parser/src/parse/utils.rs b/parser/src/parse/utils.rs index f71ca30a..346f68a9 100644 --- a/parser/src/parse/utils.rs +++ b/parser/src/parse/utils.rs @@ -9,8 +9,8 @@ pub(super) fn next_if_rule<'a>(pairs: &mut Pairs<'a, Rule>, rule: Rule) -> Optio None } } -pub(super) fn parse_if_rule<'a, T>( - pairs: &mut Pairs<'a, Rule>, +pub(super) fn parse_if_rule( + pairs: &mut Pairs, rule: Rule, f: impl FnOnce(Pair) -> Result, ) -> Result> { diff --git a/src/registry/mod.rs b/src/registry/mod.rs index 512d89d4..85ac2a3f 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -228,37 +228,19 @@ impl MetaType { } pub fn is_composite(&self) -> bool { - match self { - MetaType::Object { .. } => true, - MetaType::Interface { .. } => true, - MetaType::Union { .. } => true, - _ => false, - } + matches!(self, MetaType::Object { .. } | MetaType::Interface { .. } | MetaType::Union { .. }) } pub fn is_abstract(&self) -> bool { - match self { - MetaType::Interface { .. } => true, - MetaType::Union { .. } => true, - _ => false, - } + matches!(self, MetaType::Interface { .. } | MetaType::Union { .. }) } pub fn is_leaf(&self) -> bool { - match self { - MetaType::Enum { .. } => true, - MetaType::Scalar { .. } => true, - _ => false, - } + matches!(self, MetaType::Enum { .. } | MetaType::Scalar { .. }) } pub fn is_input(&self) -> bool { - match self { - MetaType::Enum { .. } => true, - MetaType::Scalar { .. } => true, - MetaType::InputObject { .. } => true, - _ => false, - } + matches!(self, MetaType::Enum { .. } | MetaType::Scalar { .. } | MetaType::InputObject { .. }) } pub fn is_possible_type(&self, type_name: &str) -> bool { @@ -279,7 +261,7 @@ impl MetaType { } pub fn type_overlap(&self, ty: &MetaType) -> bool { - if self as *const MetaType == ty as *const MetaType { + if std::ptr::eq(self, ty) { return true; }