From 52e12ce9afc47525347c8e3fd752a0b98c419505 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 4 Nov 2022 11:02:52 -0500 Subject: [PATCH] style: Make clippy happy --- crates/core/src/reflection.rs | 21 +++++++-------------- crates/tree/src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/crates/core/src/reflection.rs b/crates/core/src/reflection.rs index 7393c48..120d1bd 100644 --- a/crates/core/src/reflection.rs +++ b/crates/core/src/reflection.rs @@ -40,7 +40,7 @@ pub struct Parameter<'a>(&'a str, &'a dyn fmt::Display); impl<'a> Parameter<'a> { /// Create a new `Parameter`. pub fn new(key: &'a str, value: &'a dyn fmt::Display) -> Self { - Self { 0: key, 1: value } + Self(key, value) } /// Access the `Parameter` name. @@ -72,7 +72,7 @@ pub struct Child<'a>(&'a str, &'a dyn PredicateReflection); impl<'a> Child<'a> { /// Create a new `Predicate` child. pub fn new(key: &'a str, value: &'a dyn PredicateReflection) -> Self { - Self { 0: key, 1: value } + Self(key, value) } /// Access the `Child`'s name. @@ -141,16 +141,12 @@ impl<'a> Case<'a> { /// Access the by-products from determining this case. pub fn products(&self) -> CaseProducts<'_> { - CaseProducts { - 0: self.products.iter(), - } + CaseProducts(self.products.iter()) } /// Access the sub-cases. pub fn children(&self) -> CaseChildren<'_> { - CaseChildren { - 0: self.children.iter(), - } + CaseChildren(self.children.iter()) } } @@ -229,10 +225,7 @@ impl Product { S: Into>, D: fmt::Display + 'static, { - Self { - 0: key.into(), - 1: Box::new(value), - } + Self(key.into(), Box::new(value)) } /// Access the `Product` name. @@ -246,13 +239,13 @@ impl Product { } } -impl<'a> fmt::Display for Product { +impl fmt::Display for Product { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {}", self.0, self.1) } } -impl<'a> fmt::Debug for Product { +impl fmt::Debug for Product { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "({:?}, {})", self.0, self.1) } diff --git a/crates/tree/src/lib.rs b/crates/tree/src/lib.rs index 1f0f1e5..dc33e17 100644 --- a/crates/tree/src/lib.rs +++ b/crates/tree/src/lib.rs @@ -41,7 +41,7 @@ fn convert(case: &reflection::Case<'_>) -> CaseTreeInner { termtree::Tree::new(root).with_multiline(true) })); - leaves.extend(case.children().map(|item| convert(item))); + leaves.extend(case.children().map(convert)); let root = Box::new(case.predicate().map(|p| p.to_string()).unwrap_or_default()); CaseTreeInner::new(root).with_leaves(leaves)