Skip to content

Commit ab9a2c0

Browse files
committed
Restrict compression level for brotli to be >= 0
plus fixing fmt Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent df5cdd9 commit ab9a2c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Level {
171171
match self {
172172
Self::Fastest => params.quality = 0,
173173
Self::Best => params.quality = 11,
174-
Self::Precise(quality) => params.quality = quality.min(11),
174+
Self::Precise(quality) => params.quality = quality.clamp(0, 11),
175175
Self::Default => (),
176176
}
177177

@@ -190,7 +190,7 @@ impl Level {
190190
quality
191191
.try_into()
192192
.unwrap_or(0)
193-
.clamp(fastest.level(), best.level())
193+
.clamp(fastest.level(), best.level()),
194194
),
195195
Self::Default => bzip2::Compression::default(),
196196
}
@@ -208,7 +208,7 @@ impl Level {
208208
quality
209209
.try_into()
210210
.unwrap_or(0)
211-
.clamp(fastest.level(), best.level())
211+
.clamp(fastest.level(), best.level()),
212212
),
213213
Self::Default => flate2::Compression::default(),
214214
}

0 commit comments

Comments
 (0)