diff --git a/src/crc.rs b/src/crc.rs index 16f56019..991cc957 100644 --- a/src/crc.rs +++ b/src/crc.rs @@ -8,7 +8,7 @@ use crc32fast::Hasher; /// The CRC calculated by a [`CrcReader`]. /// /// [`CrcReader`]: struct.CrcReader.html -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Crc { amt: u32, hasher: Hasher, @@ -23,19 +23,10 @@ pub struct CrcReader { crc: Crc, } -impl Default for Crc { - fn default() -> Self { - Self::new() - } -} - impl Crc { /// Create a new CRC. - pub fn new() -> Crc { - Crc { - amt: 0, - hasher: Hasher::new(), - } + pub fn new() -> Self { + Self::default() } /// Returns the current crc32 checksum. diff --git a/src/gz/mod.rs b/src/gz/mod.rs index 157c517c..92440279 100644 --- a/src/gz/mod.rs +++ b/src/gz/mod.rs @@ -87,7 +87,7 @@ impl GzHeader { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub enum GzHeaderState { Start(u8, [u8; 10]), Xlen(Option>, u8, [u8; 2]), @@ -95,15 +95,10 @@ pub enum GzHeaderState { Filename(Option>), Comment(Option>), Crc(Option>, u8, [u8; 2]), + #[default] Complete, } -impl Default for GzHeaderState { - fn default() -> Self { - Self::Complete - } -} - #[derive(Debug, Default)] pub struct GzHeaderParser { state: GzHeaderState, @@ -317,7 +312,7 @@ fn corrupt() -> Error { /// # Ok(()) /// # } /// ``` -#[derive(Debug)] +#[derive(Debug, Default)] pub struct GzBuilder { extra: Option>, filename: Option, @@ -326,22 +321,10 @@ pub struct GzBuilder { mtime: u32, } -impl Default for GzBuilder { - fn default() -> Self { - Self::new() - } -} - impl GzBuilder { /// Create a new blank builder with no header by default. pub fn new() -> GzBuilder { - GzBuilder { - extra: None, - filename: None, - comment: None, - operating_system: None, - mtime: 0, - } + Self::default() } /// Configure the `mtime` field in the gzip header.