From e6968ebf56a243422182712729cb6dfee745baba Mon Sep 17 00:00:00 2001 From: Pantelis Sopasakis Date: Tue, 26 Sep 2023 18:19:35 +0100 Subject: [PATCH 1/2] clippy fixes About: - drop some unnecessary mut - Option.is_some() instead of != none --- src/alm/alm_optimizer.rs | 8 ++++---- src/constraints/rectangle.rs | 2 +- src/core/fbs/fbs_optimizer.rs | 2 +- src/core/panoc/panoc_optimizer.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/alm/alm_optimizer.rs b/src/alm/alm_optimizer.rs index 131df3f2..0fcb1fde 100644 --- a/src/alm/alm_optimizer.rs +++ b/src/alm/alm_optimizer.rs @@ -1415,7 +1415,7 @@ mod tests { "exists right away" ); - let mut alm_optimizer = alm_optimizer + let alm_optimizer = alm_optimizer .with_initial_inner_tolerance(1e-3) .with_epsilon_tolerance(1e-3); assert!(!alm_optimizer.is_exit_criterion_satisfied()); @@ -1433,7 +1433,7 @@ mod tests { let panoc_cache = PANOCCache::new(nx, tolerance, lbfgs_mem); let mut alm_cache = AlmCache::new(panoc_cache, n1, n2); let alm_problem = make_dummy_alm_problem(n1, n2); - let mut alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem) + let alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem) .with_sufficient_decrease_coefficient(0.1); // should stall because iteration = 0 @@ -1458,7 +1458,7 @@ mod tests { let panoc_cache = PANOCCache::new(nx, tolerance, lbfgs_mem); let mut alm_cache = AlmCache::new(panoc_cache, n1, n2); let alm_problem = make_dummy_alm_problem(n1, n2); - let mut alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem) + let alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem) .with_sufficient_decrease_coefficient(0.1); // should stall because iteration = 0 @@ -1483,7 +1483,7 @@ mod tests { let panoc_cache = PANOCCache::new(nx, tolerance, lbfgs_mem); let mut alm_cache = AlmCache::new(panoc_cache, n1, n2); let alm_problem = make_dummy_alm_problem(n1, n2); - let mut alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem) + let alm_optimizer = AlmOptimizer::new(&mut alm_cache, alm_problem) .with_sufficient_decrease_coefficient(0.1); // should stall because iteration = 0 diff --git a/src/constraints/rectangle.rs b/src/constraints/rectangle.rs index e7d86003..f8c8cf9f 100644 --- a/src/constraints/rectangle.rs +++ b/src/constraints/rectangle.rs @@ -35,7 +35,7 @@ impl<'a> Rectangle<'a> { /// dimensions /// pub fn new(xmin: Option<&'a [f64]>, xmax: Option<&'a [f64]>) -> Self { - assert!(xmin != None || xmax != None); // xmin or xmax must be Some + assert!(xmin.is_some() || xmax.is_some()); // xmin or xmax must be Some assert!( xmin.is_none() || xmax.is_none() || xmin.unwrap().len() == xmax.unwrap().len(), "incompatible dimensions of xmin and xmax" diff --git a/src/core/fbs/fbs_optimizer.rs b/src/core/fbs/fbs_optimizer.rs index 2b536964..d714ab67 100644 --- a/src/core/fbs/fbs_optimizer.rs +++ b/src/core/fbs/fbs_optimizer.rs @@ -63,7 +63,7 @@ where /// /// The method panics if the specified tolerance is not positive pub fn with_tolerance( - mut self, + self, tolerance: f64, ) -> FBSOptimizer<'a, GradientType, ConstraintType, CostType> { assert!(tolerance > 0.0); diff --git a/src/core/panoc/panoc_optimizer.rs b/src/core/panoc/panoc_optimizer.rs index ae2c019c..602abd45 100644 --- a/src/core/panoc/panoc_optimizer.rs +++ b/src/core/panoc/panoc_optimizer.rs @@ -62,7 +62,7 @@ where /// ## Panics /// /// The method panics if the specified tolerance is not positive - pub fn with_tolerance(mut self, tolerance: f64) -> Self { + pub fn with_tolerance(self, tolerance: f64) -> Self { assert!(tolerance > 0.0, "tolerance must be larger than 0"); self.panoc_engine.cache.tolerance = tolerance; From 6a9e88e0b6b525c697c8031384dbfb60aba49a75 Mon Sep 17 00:00:00 2001 From: Pantelis Sopasakis Date: Sun, 29 Oct 2023 01:59:17 +0000 Subject: [PATCH 2/2] update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d5ba81a..54b22078 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). Note: This is the main Changelog file for the Rust solver. The Changelog file for the Python interface (`opengen`) can be found in [/open-codegen/CHANGELOG.md](open-codegen/CHANGELOG.md) + +## Unreleased + +### Fixed + +- Clippy fixes