Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove explicit default impls #457

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,19 +23,10 @@ pub struct CrcReader<R> {
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.
Expand Down
25 changes: 4 additions & 21 deletions src/gz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,18 @@ impl GzHeader {
}
}

#[derive(Debug)]
#[derive(Debug, Default)]
pub enum GzHeaderState {
Start(u8, [u8; 10]),
Xlen(Option<Box<Crc>>, u8, [u8; 2]),
Extra(Option<Box<Crc>>, u16),
Filename(Option<Box<Crc>>),
Comment(Option<Box<Crc>>),
Crc(Option<Box<Crc>>, u8, [u8; 2]),
#[default]
Complete,
}

impl Default for GzHeaderState {
fn default() -> Self {
Self::Complete
}
}

#[derive(Debug, Default)]
pub struct GzHeaderParser {
state: GzHeaderState,
Expand Down Expand Up @@ -317,7 +312,7 @@ fn corrupt() -> Error {
/// # Ok(())
/// # }
/// ```
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct GzBuilder {
extra: Option<Vec<u8>>,
filename: Option<CString>,
Expand All @@ -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.
Expand Down