From 907e13b5b67b349bb8c9ea23554f6154065239a9 Mon Sep 17 00:00:00 2001 From: Michael Lamparski Date: Mon, 22 Jul 2019 13:24:34 -0400 Subject: [PATCH] impl Default for write::FileOptions --- examples/write_sample.rs | 4 ++-- src/write.rs | 6 ++++++ tests/end_to_end.rs | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/write_sample.rs b/examples/write_sample.rs index 697a4d66..6ff12f0b 100644 --- a/examples/write_sample.rs +++ b/examples/write_sample.rs @@ -33,13 +33,13 @@ fn doit(filename: &str) -> zip::result::ZipResult<()> let mut zip = zip::ZipWriter::new(file); - zip.add_directory("test/", FileOptions::default())?; + zip.add_directory("test/", Default::default())?; let options = FileOptions::default().compression_method(zip::CompressionMethod::Stored).unix_permissions(0o755); zip.start_file("test/☃.txt", options)?; zip.write_all(b"Hello, World!\n")?; - zip.start_file("test/lorem_ipsum.txt", FileOptions::default())?; + zip.start_file("test/lorem_ipsum.txt", Default::default())?; zip.write_all(LOREM_IPSUM)?; zip.finish()?; diff --git a/src/write.rs b/src/write.rs index 0bba9591..1c4888a8 100644 --- a/src/write.rs +++ b/src/write.rs @@ -121,6 +121,12 @@ impl FileOptions { } } +impl Default for FileOptions { + fn default() -> Self { + Self::default() + } +} + impl Write for ZipWriter { fn write(&mut self, buf: &[u8]) -> io::Result diff --git a/tests/end_to_end.rs b/tests/end_to_end.rs index 1fecf279..cd69ce3c 100644 --- a/tests/end_to_end.rs +++ b/tests/end_to_end.rs @@ -20,7 +20,7 @@ fn end_to_end() { fn write_to_zip_file(file: &mut Cursor>) -> zip::result::ZipResult<()> { let mut zip = zip::ZipWriter::new(file); - zip.add_directory("test/", FileOptions::default())?; + zip.add_directory("test/", Default::default())?; let options = FileOptions::default() .compression_method(zip::CompressionMethod::Stored) @@ -28,7 +28,7 @@ fn write_to_zip_file(file: &mut Cursor>) -> zip::result::ZipResult<()> { zip.start_file("test/☃.txt", options)?; zip.write_all(b"Hello, World!\n")?; - zip.start_file("test/lorem_ipsum.txt", FileOptions::default())?; + zip.start_file("test/lorem_ipsum.txt", Default::default())?; zip.write_all(LOREM_IPSUM)?; zip.finish()?;