Skip to content

Commit 4c9c44c

Browse files
Robert ForsmanRahix
authored andcommitted
Fix a few clippy warnings
Rebased-by: Rahix <[email protected]>
1 parent 4303bfe commit 4c9c44c

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

avr-hal-generic/src/adc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ where
184184
// Measurement on current pin completed
185185
(Some(channel), false) if *channel == pin.channel() => {
186186
self.reading_channel = None;
187-
Ok(self.p.raw_read_adc().into())
187+
Ok(self.p.raw_read_adc())
188188
}
189189
// Measurement on other pin is ongoing
190190
(Some(_), _) => {
@@ -298,7 +298,7 @@ macro_rules! impl_adc {
298298
$(#[$channel_attr])*
299299
impl $channel_ty {
300300
pub fn into_channel(self) -> $crate::adc::Channel<$HAL, $ADC> {
301-
crate::adc::Channel::new(self)
301+
$crate::adc::Channel::new(self)
302302
}
303303
}
304304
)*)?

avr-hal-generic/src/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ macro_rules! impl_i2c_twi {
404404
> for $I2C
405405
{
406406
#[inline]
407-
fn raw_setup<CLOCK: crate::clock::Clock>(&mut self, speed: u32) {
407+
fn raw_setup<CLOCK: $crate::clock::Clock>(&mut self, speed: u32) {
408408
// Calculate TWBR register value
409409
let twbr = ((CLOCK::FREQ / speed) - 16) / 2;
410410
self.twbr.write(|w| unsafe { w.bits(twbr as u8) });

avr-hal-generic/src/usart.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ impl<CLOCK: crate::clock::Clock> Baudrate<CLOCK> {
7979

8080
fn compare_value(&self) -> u32 {
8181
if self.u2x {
82-
return 8 * (self.ubrr as u32 + 1);
82+
8 * (self.ubrr as u32 + 1)
8383
} else {
84-
return 16 * (self.ubrr as u32 + 1);
85-
};
84+
16 * (self.ubrr as u32 + 1)
85+
}
8686
}
8787
}
8888

examples/arduino-uno/src/bin/uno-ext-interrupt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
#![feature(abi_avr_interrupt)]
1111

1212
use panic_halt as _;
13-
use core::ops::Range;
1413
use core::sync::atomic::{AtomicBool, Ordering};
1514
use arduino_hal::port::{mode, Pin};
1615
use either::*;
1716

1817
static REVERSED: AtomicBool = AtomicBool::new(false);
1918

2019
fn is_reversed() -> bool {
21-
return REVERSED.load(Ordering::SeqCst);
20+
REVERSED.load(Ordering::SeqCst)
2221
}
2322

2423
#[avr_device::interrupt(atmega328p)]
@@ -27,7 +26,7 @@ fn INT0() {
2726
REVERSED.store(!current, Ordering::SeqCst);
2827
}
2928

30-
fn blink_for_range(range : Range<u16>, leds : &mut[Pin<mode::Output>]) {
29+
fn blink_for_range(range: impl Iterator<Item = u16>, leds: &mut [Pin<mode::Output>]) {
3130
range.map(|i| i * 100).for_each(|ms| {
3231
let iter = if is_reversed() {
3332
Left(leds.iter_mut().rev())
@@ -63,6 +62,6 @@ fn main() -> ! {
6362

6463
loop {
6564
blink_for_range(0..10, &mut leds);
66-
blink_for_range(10..0, &mut leds);
65+
blink_for_range((0..10).rev(), &mut leds);
6766
}
6867
}

examples/arduino-uno/src/bin/uno-i2cdetect.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@ fn main() -> ! {
4040
i2c.i2cdetect(&mut serial, arduino_hal::i2c::Direction::Read)
4141
.void_unwrap();
4242

43-
loop {}
43+
loop {
44+
arduino_hal::delay_ms(1000);
45+
}
4446
}

examples/arduino-uno/src/bin/uno-infrared.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*!
32
* Example for receiving IR signals from a remote control using an [Irdroino] shield
43
* and the [Infrared] crate.

examples/arduino-uno/src/bin/uno-pin-change-interrupt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
#![no_main]
1010
#![feature(abi_avr_interrupt)]
1111

12-
use arduino_hal;
1312
use panic_halt as _;
1413

15-
use core:: sync::atomic::{AtomicBool, Ordering};
14+
use core::sync::atomic::{AtomicBool, Ordering};
1615

1716
static PIN_CHANGED: AtomicBool = AtomicBool::new(false);
1817

@@ -42,11 +41,11 @@ fn main() -> ! {
4241
//Pins used to drive the stepper motor
4342
let mut dir_pin = pins.d4.into_output();
4443
let mut step_pin = pins.d5.into_output();
45-
44+
4645
//Rotary encoder attached on these pins
4746
let rotary_pins = [
4847
pins.d2.into_floating_input().downgrade(), //CLK
49-
pins.d3.into_floating_input().downgrade() //DT
48+
pins.d3.into_floating_input().downgrade(), //DT
5049
];
5150

5251
// Enable the PCINT2 pin change interrupt

0 commit comments

Comments
 (0)