Skip to content

Commit

Permalink
Use #[derive(Default)] instead of implementing it on manually
Browse files Browse the repository at this point in the history
This feature has been stabilized as of 1.62
rust-lang/rust#94457
  • Loading branch information
fsktom committed Jul 5, 2022
1 parent a71dd52 commit c93bc6e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ pub enum AspectFull<'a> {
Song(&'a Song),
}

// you can derive Default in Rust 1.62 https://github.com/rust-lang/rust/pull/94457/
#[derive(Default)]
pub enum Aspect {
Artists,
Albums,
// bc Rust still doesn't have default argument values
// https://www.reddit.com/r/rust/comments/fi6nov/why_does_rust_not_support_default_arguments/fkfezxv/
#[default]
Songs,
}

// bc Rust still doesn't have default argument values
// https://www.reddit.com/r/rust/comments/fi6nov/why_does_rust_not_support_default_arguments/fkfezxv/
impl Default for Aspect {
fn default() -> Self {
Aspect::Songs
}
}

pub trait Music: Display {}

#[derive(PartialEq, Eq, Hash, Debug, Clone)]
Expand Down

0 comments on commit c93bc6e

Please sign in to comment.