Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
emuell committed Jun 25, 2024
1 parent b3295c3 commit 55261a8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/bindings/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ impl LuaUserData for Scale {
let args = args.into_vec();
// parse degree
let mut degree = 1;
if !args.is_empty() {
degree = note_degree_from_value(args.get(0).unwrap(), 1)?;
#[allow(clippy::get_first)]
if let Some(degree_value) = args.get(0) {
degree = note_degree_from_value(degree_value, 1)?;
}
// parse count
let mut count = 3;
if args.len() >= 2 {
if let Some(count_value) = args.get(1) {
let count_error = || {
Err(bad_argument_error(
"chord",
Expand All @@ -37,7 +38,7 @@ impl LuaUserData for Scale {
"number of notes must be an integer in range [1..=5]",
))
};
if let Some(value) = args.get(1).unwrap().as_usize() {
if let Some(value) = count_value.as_usize() {
count = value;
if !(1..=5).contains(&count) {
return count_error();
Expand Down
6 changes: 3 additions & 3 deletions src/bindings/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'lua> FromLua<'lua> for Note {
})
}
_ => {
return Err(LuaError::FromLuaConversionError {
Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "note",
message: Some("expected a note number or note string".to_string()),
Expand Down Expand Up @@ -517,15 +517,15 @@ pub(crate) fn note_event_from_value(
LuaValue::String(str) => note_event_from_string(&str.to_string_lossy()),
LuaValue::Table(table) => note_event_from_table_map(table),
_ => {
return Err(LuaError::FromLuaConversionError {
Err(LuaError::FromLuaConversionError {
from: arg.type_name(),
to: "note",
message: if let Some(index) = arg_index {
Some(format!("arg #{} is not a valid note property", index + 1).to_string())
} else {
Some("invalid note property".to_string())
},
});
})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/event/mutated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl EventIter for MutatedEventIter {
}

fn reset(&mut self) {
self.events = self.initial_events.clone();
self.events.clone_from(&self.initial_events);
self.event_index = 0;
self.map = (self.reset_map)();
}
Expand Down
2 changes: 1 addition & 1 deletion src/pattern/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Pattern for FixedPattern {
}
// reset pulse iter and fetch first pulse from it
let mut pulse_iter = self.pulses[self.pulse_index].clone().into_iter();
let pulse = pulse_iter.next().unwrap_or(PulseIterItem::default());
let pulse = pulse_iter.next().unwrap_or_default();
self.pulse_iter = Some(pulse_iter);
Some(pulse)
}
Expand Down
8 changes: 4 additions & 4 deletions src/phrase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ impl Phrase {
}
RhythmSlot::Continue => {
// take over pending events
self.next_events[rhythm_index] =
previous_phrase.next_events[rhythm_index].clone();
self.next_events[rhythm_index]
.clone_from(&previous_phrase.next_events[rhythm_index]);
// take over rhythm
self.rhythm_slots[rhythm_index] =
previous_phrase.rhythm_slots[rhythm_index].clone();
self.rhythm_slots[rhythm_index]
.clone_from(&previous_phrase.rhythm_slots[rhythm_index]);
}
}
}
Expand Down

0 comments on commit 55261a8

Please sign in to comment.