From 9670ca757a448e6d344a8cf9ae553ce709867db5 Mon Sep 17 00:00:00 2001 From: paripal Date: Mon, 17 Jun 2024 09:55:06 +0900 Subject: [PATCH] fix: code formatting --- src/buffered_cobs.rs | 2 ++ src/encoder.rs | 8 ++++---- src/scheduler.rs | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/buffered_cobs.rs b/src/buffered_cobs.rs index de7231c..d829064 100644 --- a/src/buffered_cobs.rs +++ b/src/buffered_cobs.rs @@ -1,3 +1,4 @@ +#[allow(dead_code)] pub struct BufferedCobs { buffer: [u8; BUFFER_SIZE], buffer_index: usize, @@ -5,6 +6,7 @@ pub struct BufferedCobs { data_ready: u16, } +#[allow(dead_code)] impl BufferedCobs { pub fn new() -> BufferedCobs { BufferedCobs:: { diff --git a/src/encoder.rs b/src/encoder.rs index 899ebcd..277d54b 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -25,7 +25,7 @@ where PinA: hal::gpio::ValidFunction, PinB: hal::gpio::ValidFunction, { - pub fn configure<'a, F1A, P1A, F1B, P1B>( + pub fn configure( &self, pin_a: hal::gpio::Pin, pin_b: hal::gpio::Pin, @@ -78,9 +78,9 @@ where self.last_speed_update_count.borrow(cs).replace(count); }); - return Ok((Into::::into(count_delta) * 0x100 * 1_000_000 / delta) + Ok((Into::::into(count_delta) * 0x100 * 1_000_000 / delta) .try_into() - .unwrap()); + .unwrap()) } pub const fn none() -> Self { Encoder:: { @@ -112,7 +112,7 @@ where PinA: hal::gpio::ValidFunction, PinB: hal::gpio::ValidFunction, { - pub fn new<'a, F1A, P1A, F1B, P1B>( + pub fn new( pin_a: hal::gpio::Pin, pin_b: hal::gpio::Pin, ) -> Self diff --git a/src/scheduler.rs b/src/scheduler.rs index 6a8e092..905e411 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -9,18 +9,18 @@ pub struct Scheduler<'a> { impl<'a> Scheduler<'a> { pub fn new(wait_tick: u64, timer: &'a hal::Timer) -> Scheduler<'a> { Scheduler::<'a> { - wait_tick: wait_tick, + wait_tick, next_update: timer.get_counter().ticks() + wait_tick, - timer: timer, + timer, } } pub fn update(&mut self) -> bool { let tick = self.timer.get_counter().ticks(); if tick >= self.next_update { self.next_update += self.wait_tick; - return true; + true } else { - return false; + false } } }