Skip to content

Commit

Permalink
clippy fixes for rust 1.75.0
Browse files Browse the repository at this point in the history
  • Loading branch information
orottier committed Dec 29, 2023
1 parent c1cae4b commit 585f8aa
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl AudioBuffer {

/// Number of samples per channel in this `AudioBuffer`
pub fn length(&self) -> usize {
self.channels.get(0).map(ChannelData::len).unwrap_or(0)
self.channels.first().map(ChannelData::len).unwrap_or(0)
}

/// Sample rate of this `AudioBuffer` in Hertz
Expand Down
2 changes: 1 addition & 1 deletion src/context/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl AudioContext {
let mut pending_msgs: Vec<_> = self.render_thread_init.ctrl_msg_recv.try_iter().collect();

// Acquire the active audio graph from the current render thread, shutting it down
let graph = if matches!(pending_msgs.get(0), Some(ControlMessage::Startup { .. })) {
let graph = if matches!(pending_msgs.first(), Some(ControlMessage::Startup { .. })) {
// Handle the edge case where the previous backend was suspended for its entire lifetime.
// In this case, the `Startup` control message was never processed.
let msg = pending_msgs.remove(0);
Expand Down
4 changes: 2 additions & 2 deletions src/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ impl AudioParamEventTimeline {
}

fn unsorted_peek(&self) -> Option<&AudioParamEvent> {
self.inner.get(0)
self.inner.first()
}

// panic if dirty, we are doing something wrong here
fn peek(&self) -> Option<&AudioParamEvent> {
if self.dirty {
panic!("`AudioParamEventTimeline`: Invalid `.peek()` call, the queue is dirty");
}
self.inner.get(0)
self.inner.first()
}

fn next(&self) -> Option<&AudioParamEvent> {
Expand Down
2 changes: 1 addition & 1 deletion src/render/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Node {

/// Get the current buffer for AudioParam values
pub fn get_buffer(&self) -> &AudioRenderQuantum {
self.outputs.get(0).unwrap()
self.outputs.first().unwrap()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/render/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl RenderThread {

for quantum in 0..num_frames {
// Suspend at given times and run callbacks
if suspend_callbacks.get(0).map(|&(q, _)| q) == Some(quantum) {
if suspend_callbacks.first().map(|&(q, _)| q) == Some(quantum) {
let callback = suspend_callbacks.remove(0).1;
(callback)(context);

Expand Down Expand Up @@ -243,7 +243,7 @@ impl RenderThread {

for quantum in 0..num_frames {
// Suspend at given times and run callbacks
if suspend_callbacks.get(0).map(|&(q, _)| q) == Some(quantum) {
if suspend_callbacks.first().map(|&(q, _)| q) == Some(quantum) {
let sender = suspend_callbacks.remove(0).1;
sender.send(()).unwrap();
resume_receiver.next().await;
Expand Down
2 changes: 1 addition & 1 deletion src/worklet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl AudioProcessor for AudioWorkletRenderer {
// Create an iterator for the output channel counts without allocating, handling also the
// case where self.output_channel_count is empty.
let single_case = [inputs
.get(0)
.first()
.map(|i| i.number_of_channels())
.unwrap_or_default()];
let output_channel_count = if self.output_channel_count.is_empty() {
Expand Down

0 comments on commit 585f8aa

Please sign in to comment.