Use {:?} and Box::new

This commit is contained in:
Mathijs van de Nes 2015-01-10 09:35:39 +01:00
parent 38492c5dce
commit 1a62f9ce16
3 changed files with 10 additions and 10 deletions

View file

@ -13,7 +13,7 @@ fn main()
match doit(filename) match doit(filename)
{ {
Ok(_) => println!("File written to {}", filename), Ok(_) => println!("File written to {}", filename),
Err(e) => println!("Error: {}", e), Err(e) => println!("Error: {:?}", e),
} }
} }

View file

@ -32,7 +32,7 @@ use bzip2::reader::BzDecompressor;
/// Ok(()) /// Ok(())
/// } /// }
/// ///
/// println!("Result: {}", doit()); /// println!("Result: {:?}", doit());
/// ``` /// ```
pub struct ZipReader<T> pub struct ZipReader<T>
{ {
@ -109,28 +109,28 @@ impl<T: Reader+Seek> ZipReader<T>
{ {
CompressionMethod::Stored => CompressionMethod::Stored =>
{ {
box Box::new(
Crc32Reader::new( Crc32Reader::new(
limit_reader, limit_reader,
file.crc32) file.crc32))
as Box<Reader> as Box<Reader>
}, },
CompressionMethod::Deflated => CompressionMethod::Deflated =>
{ {
let deflate_reader = limit_reader.deflate_decode(); let deflate_reader = limit_reader.deflate_decode();
box Box::new(
Crc32Reader::new( Crc32Reader::new(
deflate_reader, deflate_reader,
file.crc32) file.crc32))
as Box<Reader> as Box<Reader>
}, },
CompressionMethod::Bzip2 => CompressionMethod::Bzip2 =>
{ {
let bzip2_reader = BzDecompressor::new(limit_reader); let bzip2_reader = BzDecompressor::new(limit_reader);
box Box::new(
Crc32Reader::new( Crc32Reader::new(
bzip2_reader, bzip2_reader,
file.crc32) file.crc32))
as Box<Reader> as Box<Reader>
}, },
_ => return unsupported_zip_error("Compression method not supported"), _ => return unsupported_zip_error("Compression method not supported"),

View file

@ -41,7 +41,7 @@ enum GenericZipWriter<W>
/// Ok(()) /// Ok(())
/// } /// }
/// ///
/// println!("Result: {}", doit()); /// println!("Result: {:?}", doit());
/// ``` /// ```
pub struct ZipWriter<W> pub struct ZipWriter<W>
{ {
@ -209,7 +209,7 @@ impl<W: Writer+Seek> Drop for ZipWriter<W>
match self.finalize() match self.finalize()
{ {
Ok(_) => {}, Ok(_) => {},
Err(e) => warn!("ZipWriter drop failed: {}", e), Err(e) => warn!("ZipWriter drop failed: {:?}", e),
} }
} }
} }