From 0b83b1a08b0774044be92875b65ad8990b7fe5c7 Mon Sep 17 00:00:00 2001 From: eth3lbert Date: Sat, 23 Nov 2024 18:17:59 +0800 Subject: [PATCH] Adjust `Level::Precise` clamp range for flate2 Previously, the clamp range was from "fastest" to "best" (1-9). This commit changes the range to start from "none" (0) to allow for no compression. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 40f84a4..91d906c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -216,6 +216,7 @@ impl Level { fn into_flate2(self) -> flate2::Compression { let fastest = flate2::Compression::fast(); let best = flate2::Compression::best(); + let none = flate2::Compression::none(); match self { Self::Fastest => fastest, @@ -224,7 +225,7 @@ impl Level { quality .try_into() .unwrap_or(0) - .clamp(fastest.level(), best.level()), + .clamp(none.level(), best.level()), ), Self::Default => flate2::Compression::default(), }