From 97af09f238cbf53e2d6dcf6b137a708ac875f997 Mon Sep 17 00:00:00 2001 From: Steve Loveless Date: Fri, 2 Feb 2024 16:57:45 -0800 Subject: [PATCH] clippy --- api/benches/measurements_benchmarks.rs | 1 - api/benches/unit_benchmarks.rs | 1 - api/src/parser.rs | 2 +- api/src/parser/terms/mapper.rs | 22 +++++++++++----------- api/src/parser/terms/mapper/ast_term.rs | 2 +- api/src/unit.rs | 5 +++-- api/src/unit/deref.rs | 2 +- api/src/unit/ops.rs | 2 +- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/api/benches/measurements_benchmarks.rs b/api/benches/measurements_benchmarks.rs index 0a252079..9cafa4c6 100644 --- a/api/benches/measurements_benchmarks.rs +++ b/api/benches/measurements_benchmarks.rs @@ -71,4 +71,3 @@ criterion_group!( convert_to_unit_group, ); criterion_main!(measurement_benches); - diff --git a/api/benches/unit_benchmarks.rs b/api/benches/unit_benchmarks.rs index 360151a0..5b073e14 100644 --- a/api/benches/unit_benchmarks.rs +++ b/api/benches/unit_benchmarks.rs @@ -149,4 +149,3 @@ criterion_group!( partial_ord_gt_group, ); criterion_main!(unit_benches); - diff --git a/api/src/parser.rs b/api/src/parser.rs index 14a3af33..b8edd2f3 100644 --- a/api/src/parser.rs +++ b/api/src/parser.rs @@ -18,7 +18,7 @@ pub mod composition; #[allow(clippy::non_ascii_literal)] pub mod property; -pub(self) mod symbols; +mod symbols; mod annotation_composition; #[cfg(test)] diff --git a/api/src/parser/terms/mapper.rs b/api/src/parser/terms/mapper.rs index 48da2451..146797c3 100644 --- a/api/src/parser/terms/mapper.rs +++ b/api/src/parser/terms/mapper.rs @@ -3,17 +3,17 @@ // Internal structs for mapping parser Rule data to an intermediate // representation of a Unit. -pub(self) mod annotatable; -pub(self) mod annotation; -pub(self) mod ast_term; -pub(self) mod basic_component; -pub(self) mod component; -pub(self) mod digits; -pub(self) mod exponent; -pub(self) mod factor; -pub(self) mod finishable; -pub(self) mod main_term; -pub(self) mod simple_unit; +mod annotatable; +mod annotation; +mod ast_term; +mod basic_component; +mod component; +mod digits; +mod exponent; +mod factor; +mod finishable; +mod main_term; +mod simple_unit; use self::{ annotatable::Annotatable, annotation::Annotation, ast_term::AstTerm, diff --git a/api/src/parser/terms/mapper/ast_term.rs b/api/src/parser/terms/mapper/ast_term.rs index 27e33b85..b7392a24 100644 --- a/api/src/parser/terms/mapper/ast_term.rs +++ b/api/src/parser/terms/mapper/ast_term.rs @@ -65,7 +65,7 @@ enum SecondToken { impl Finishable for AstTerm { fn finish(self) -> Vec { let mut component_terms = self.component.finish(); - component_terms.extend(self.terms.into_iter()); + component_terms.extend(self.terms); component_terms } diff --git a/api/src/unit.rs b/api/src/unit.rs index 573c3b43..84eb1b9d 100644 --- a/api/src/unit.rs +++ b/api/src/unit.rs @@ -90,8 +90,9 @@ impl Unit { /// Creates a new `Unit` that's equivalent to "1". /// + #[deprecated(since = "0.23.0", note = "Please use unit::UNITY instead")] #[must_use] - pub fn new_unity() -> Self { + pub const fn new_unity() -> Self { UNITY } @@ -178,7 +179,7 @@ mod tests { #[test] fn validate_is_unity() { - let unit = Unit::new_unity(); + let unit = UNITY; assert!(unit.is_unity()); let unit = Unit::new(Vec::new()); diff --git a/api/src/unit/deref.rs b/api/src/unit/deref.rs index 9b8e7105..11263035 100644 --- a/api/src/unit/deref.rs +++ b/api/src/unit/deref.rs @@ -7,6 +7,6 @@ impl ::std::ops::Deref for Unit { type Target = [Term]; fn deref(&self) -> &[Term] { - &*self.terms + &self.terms } } diff --git a/api/src/unit/ops.rs b/api/src/unit/ops.rs index 94ec3b44..0337b545 100644 --- a/api/src/unit/ops.rs +++ b/api/src/unit/ops.rs @@ -9,7 +9,7 @@ fn divide_terms(lhs: &[Term], rhs: &[Term]) -> Vec { let mut terms = Vec::with_capacity(lhs.len() + rhs.len()); terms.extend_from_slice(lhs); - for term in rhs.iter() { + for term in rhs { terms.push(term.to_inverse()); }