From 37a10aea963e1dbdf5e43bf7a9d5480bf0071ad1 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Thu, 16 May 2024 15:19:36 +0100 Subject: [PATCH] Use Reverse() helper instead of sorting then reversing --- crates/config/src/sections/passwords.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/config/src/sections/passwords.rs b/crates/config/src/sections/passwords.rs index 981565727..6296f2841 100644 --- a/crates/config/src/sections/passwords.rs +++ b/crates/config/src/sections/passwords.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::cmp::Reverse; + use anyhow::bail; use camino::Utf8PathBuf; use schemars::JsonSchema; @@ -104,9 +106,8 @@ impl PasswordsConfig { &self, ) -> Result, Option>)>, anyhow::Error> { let mut schemes: Vec<&HashingScheme> = self.schemes.iter().collect(); - schemes.sort_unstable_by_key(|a| a.version); + schemes.sort_unstable_by_key(|a| Reverse(a.version)); schemes.dedup_by_key(|a| a.version); - schemes.reverse(); if schemes.len() != self.schemes.len() { // Some schemes had duplicated versions