Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Use Reverse() helper instead of sorting then reversing
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre authored and sandhose committed May 16, 2024
1 parent d20b0a0 commit 37a10ae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/config/src/sections/passwords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,9 +106,8 @@ impl PasswordsConfig {
&self,
) -> Result<Vec<(u16, Algorithm, Option<u32>, Option<Vec<u8>>)>, 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
Expand Down

0 comments on commit 37a10ae

Please sign in to comment.