Use Default::default which is nicer

This commit is contained in:
Gwilym Inzani 2023-11-15 14:44:28 +00:00
parent 2e453e8e0f
commit b583ba22a9
2 changed files with 4 additions and 14 deletions

View file

@ -209,12 +209,7 @@ pub fn parse_midi(midi_info: &MidiInfo) -> TokenStream {
let channel_data = &mut channel_data[channel_id];
let pattern = &mut patterns[channel_id];
pattern.resize_with((current_ticks as usize).saturating_sub(1), || PatternSlot {
speed: 0.into(),
sample: 0,
effect1: PatternEffect::None,
effect2: PatternEffect::None,
});
pattern.resize_with((current_ticks as usize).saturating_sub(1), Default::default);
match message {
midly::MidiMessage::NoteOff { .. } => pattern.push(PatternSlot {
@ -329,12 +324,7 @@ pub fn parse_midi(midi_info: &MidiInfo) -> TokenStream {
});
for pattern in &mut patterns {
pattern.resize_with(current_ticks as usize, || PatternSlot {
speed: 0.into(),
sample: 0,
effect1: PatternEffect::None,
effect2: PatternEffect::None,
});
pattern.resize_with(current_ticks as usize, Default::default);
}
let frames_per_tick = initial_microseconds_per_beat.expect("No tempo was ever sent") as f64

View file

@ -32,7 +32,7 @@ pub struct Pattern {
pub start_position: usize,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PatternSlot {
pub speed: Num<u16, 8>,
pub sample: u16,
@ -48,7 +48,7 @@ pub struct Envelope<'a> {
pub loop_end: Option<usize>,
}
#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub enum PatternEffect {
/// Don't play an effect
#[default]