chore: Fix errors by moving use statements inside the cfg-guarded function that uses them

This commit is contained in:
Chris Hennick 2024-05-02 18:04:05 -07:00
parent 5a3126894c
commit 63793a32ff
No known key found for this signature in database
GPG key ID: DA47AABA4961C509

View file

@ -1,8 +1,5 @@
//! Write a huge file with lots of zeros, that should compress perfectly. //! Write a huge file with lots of zeros, that should compress perfectly.
use std::io::Write;
use zip::write::SimpleFileOptions;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
if !cfg!(feature = "_deflate-any") { if !cfg!(feature = "_deflate-any") {
return Err("Please enable one of the deflate features".into()); return Err("Please enable one of the deflate features".into());
@ -22,6 +19,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "_deflate-any")] #[cfg(feature = "_deflate-any")]
fn doit(filename: &str) -> zip::result::ZipResult<()> { fn doit(filename: &str) -> zip::result::ZipResult<()> {
use std::io::Write;
use zip::write::SimpleFileOptions;
let file = std::fs::File::create(filename)?; let file = std::fs::File::create(filename)?;
let mut zip = zip::ZipWriter::new(file); let mut zip = zip::ZipWriter::new(file);