Use default macro

This commit is contained in:
JasonLG1979 2023-06-21 19:24:40 -05:00
parent 35b94bdc94
commit 7dae33c4f0

View file

@ -3,9 +3,10 @@ use std::{mem, str::FromStr, time::Duration};
pub use crate::dither::{mk_ditherer, DithererBuilder, TriangularDitherer}; pub use crate::dither::{mk_ditherer, DithererBuilder, TriangularDitherer};
use crate::{convert::i24, player::duration_to_coefficient}; use crate::{convert::i24, player::duration_to_coefficient};
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum Bitrate { pub enum Bitrate {
Bitrate96, Bitrate96,
#[default]
Bitrate160, Bitrate160,
Bitrate320, Bitrate320,
} }
@ -22,19 +23,14 @@ impl FromStr for Bitrate {
} }
} }
impl Default for Bitrate { #[derive(Clone, Copy, Debug, Default, Hash, PartialOrd, Ord, PartialEq, Eq)]
fn default() -> Self {
Self::Bitrate160
}
}
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum AudioFormat { pub enum AudioFormat {
F64, F64,
F32, F32,
S32, S32,
S24, S24,
S24_3, S24_3,
#[default]
S16, S16,
} }
@ -53,12 +49,6 @@ impl FromStr for AudioFormat {
} }
} }
impl Default for AudioFormat {
fn default() -> Self {
Self::S16
}
}
impl AudioFormat { impl AudioFormat {
// not used by all backends // not used by all backends
#[allow(dead_code)] #[allow(dead_code)]
@ -73,10 +63,11 @@ impl AudioFormat {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum NormalisationType { pub enum NormalisationType {
Album, Album,
Track, Track,
#[default]
Auto, Auto,
} }
@ -92,15 +83,10 @@ impl FromStr for NormalisationType {
} }
} }
impl Default for NormalisationType { #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
fn default() -> Self {
Self::Auto
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NormalisationMethod { pub enum NormalisationMethod {
Basic, Basic,
#[default]
Dynamic, Dynamic,
} }
@ -115,12 +101,6 @@ impl FromStr for NormalisationMethod {
} }
} }
impl Default for NormalisationMethod {
fn default() -> Self {
Self::Dynamic
}
}
#[derive(Clone)] #[derive(Clone)]
pub struct PlayerConfig { pub struct PlayerConfig {
pub bitrate: Bitrate, pub bitrate: Bitrate,