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 {