Skip to content

Commit

Permalink
perf(range): remove unnecessary collect()
Browse files Browse the repository at this point in the history
  • Loading branch information
cijiugechu committed Nov 15, 2024
1 parent ddcd36b commit 6bcbbb7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,7 @@ impl Range {
#[doc = include_str!("../examples/max_satisfying.rs")]
///
pub fn max_satisfying<'v>(&self, versions: &'v [Version]) -> Option<&'v Version> {
let filtered: Vec<_> = versions.iter().filter(|v| self.satisfies(v)).collect();

filtered.into_iter().max()
versions.iter().filter(|v| self.satisfies(v)).max()
}

/// Return the lowest [Version] in the list that satisfies the range,
Expand All @@ -495,9 +493,7 @@ impl Range {
#[doc = include_str!("../examples/min_satisfying.rs")]
///
pub fn min_satisfying<'v>(&self, versions: &'v [Version]) -> Option<&'v Version> {
let filtered: Vec<_> = versions.iter().filter(|v| self.satisfies(v)).collect();

filtered.into_iter().min()
versions.iter().filter(|v| self.satisfies(v)).min()
}

/**
Expand Down

0 comments on commit 6bcbbb7

Please sign in to comment.