Skip to content

Commit dbea59b

Browse files
committed
fix new clippy lints
1 parent c4858d3 commit dbea59b

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020

2121
- Add CAN bus abstraction based on the [bxcan] crate.
2222
- Add PWM output generation based on the timers.
23+
- Added `impl From<KiloHertz> for Hertz`
24+
- Added `impl From<MegaHertz> for Hertz`
25+
- Added `impl From<KiloHertz> for MegaHertz`
26+
- Added `impl From<Hertz> for IwdgTimeout`
2327

2428
[bxcan]: https://crates.io/crates/bxcan
2529

src/rcc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub enum HSEBypassMode {
5858
feature = "stm32f072",
5959
feature = "stm32f078",
6060
))]
61+
#[allow(clippy::upper_case_acronyms)]
6162
pub enum USBClockSource {
6263
#[cfg(feature = "stm32f070")]
6364
/// USB peripheral's tranceiver is disabled
@@ -89,6 +90,7 @@ mod inner {
8990
))]
9091
pub(super) const RCC_PLLSRC_PREDIV1_SUPPORT: bool = false;
9192

93+
#[allow(clippy::upper_case_acronyms)]
9294
pub(super) enum SysClkSource {
9395
HSI,
9496
/// High-speed external clock(freq,bypassed)
@@ -205,6 +207,7 @@ mod inner {
205207
))]
206208
pub(super) const RCC_PLLSRC_PREDIV1_SUPPORT: bool = false;
207209

210+
#[allow(clippy::upper_case_acronyms)]
208211
pub(super) enum SysClkSource {
209212
HSI,
210213
/// High-speed external clock(freq,bypassed)

src/time.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ impl U32Ext for u32 {
4444
}
4545
}
4646

47-
impl Into<Hertz> for KiloHertz {
48-
fn into(self) -> Hertz {
49-
Hertz(self.0 * 1_000)
47+
impl From<KiloHertz> for Hertz {
48+
fn from(khz: KiloHertz) -> Self {
49+
Hertz(khz.0 * 1_000)
5050
}
5151
}
5252

53-
impl Into<Hertz> for MegaHertz {
54-
fn into(self) -> Hertz {
55-
Hertz(self.0 * 1_000_000)
53+
impl From<MegaHertz> for Hertz {
54+
fn from(mhz: MegaHertz) -> Self {
55+
Hertz(mhz.0 * 1_000_000)
5656
}
5757
}
5858

59-
impl Into<KiloHertz> for MegaHertz {
60-
fn into(self) -> KiloHertz {
61-
KiloHertz(self.0 * 1_000)
59+
impl From<MegaHertz> for KiloHertz {
60+
fn from(mhz: MegaHertz) -> Self {
61+
KiloHertz(mhz.0 * 1_000)
6262
}
6363
}

src/watchdog.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ pub struct IwdgTimeout {
6666
reload: u16,
6767
}
6868

69-
impl Into<IwdgTimeout> for Hertz {
69+
impl From<Hertz> for IwdgTimeout {
7070
/// This converts the value so it's usable by the IWDG
7171
/// Due to conversion losses, the specified frequency is a maximum
7272
///
7373
/// It can also only represent values < 10000 Hertz
74-
fn into(self) -> IwdgTimeout {
75-
let mut time = 40_000 / 4 / self.0;
74+
fn from(hz: Hertz) -> Self {
75+
let mut time = 40_000 / 4 / hz.0;
7676
let mut psc = 0;
7777
let mut reload = 0;
7878
while psc < 7 {

0 commit comments

Comments
 (0)