Skip to content

Commit df5cdd9

Browse files
NobodyXurobjtede
andauthored
Apply suggestions from code review
Co-authored-by: Rob Ede <robjtede@icloud.com>
1 parent 95ae6fe commit df5cdd9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ impl Level {
190190
quality
191191
.try_into()
192192
.unwrap_or(0)
193-
.max(fastest.level())
194-
.min(best.level()),
193+
.clamp(fastest.level(), best.level())
195194
),
196195
Self::Default => bzip2::Compression::default(),
197196
}
@@ -209,8 +208,7 @@ impl Level {
209208
quality
210209
.try_into()
211210
.unwrap_or(0)
212-
.max(fastest.level())
213-
.min(best.level()),
211+
.clamp(fastest.level(), best.level())
214212
),
215213
Self::Default => flate2::Compression::default(),
216214
}
@@ -222,7 +220,7 @@ impl Level {
222220
match self {
223221
Self::Fastest => fastest,
224222
Self::Best => best,
225-
Self::Precise(quality) => quality.max(fastest).min(best),
223+
Self::Precise(quality) => quality.clamp(fastest, best),
226224
Self::Default => libzstd::DEFAULT_COMPRESSION_LEVEL,
227225
}
228226
}

0 commit comments

Comments
 (0)