From 9a32d129ff5f5abd904841f616905f583db181eb Mon Sep 17 00:00:00 2001 From: Rouven Spreckels Date: Mon, 28 Mar 2022 11:43:25 +0200 Subject: [PATCH] Fix build with `--no-default-features`. --- src/write.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/write.rs b/src/write.rs index 3d0e0170..551b4e32 100644 --- a/src/write.rs +++ b/src/write.rs @@ -11,7 +11,6 @@ use std::default::Default; use std::io; use std::io::prelude::*; use std::mem; -use std::ops::RangeInclusive; #[cfg(any( feature = "deflate", @@ -977,19 +976,32 @@ impl GenericZipWriter { } } -fn deflate_compression_level_range() -> RangeInclusive { +#[cfg(any( + feature = "deflate", + feature = "deflate-miniz", + feature = "deflate-zlib" +))] +fn deflate_compression_level_range() -> std::ops::RangeInclusive { let min = flate2::Compression::none().level() as i32; let max = flate2::Compression::best().level() as i32; min..=max } -fn bzip2_compression_level_range() -> RangeInclusive { +#[cfg(feature = "bzip2")] +fn bzip2_compression_level_range() -> std::ops::RangeInclusive { let min = bzip2::Compression::none().level() as i32; let max = bzip2::Compression::best().level() as i32; min..=max } -fn clamp_opt(value: T, range: RangeInclusive) -> Option { +#[cfg(any( + feature = "deflate", + feature = "deflate-miniz", + feature = "deflate-zlib", + feature = "bzip2", + feature = "zstd" +))] +fn clamp_opt(value: T, range: std::ops::RangeInclusive) -> Option { if range.contains(&value) { Some(value) } else {