Skip to content

Commit 6c04442

Browse files
committed
clippy
1 parent 0a0b364 commit 6c04442

File tree

2 files changed

+119
-119
lines changed

2 files changed

+119
-119
lines changed

src/gpio/alt.rs

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -7,149 +7,149 @@ macro_rules! pin {
77
( $($(#[$docs:meta])* <$name:ident> for $(no: $NoPin:ty,)? [$(
88
$(#[$attr:meta])* $PX:ident<$A:literal $(, $Otype:ident)?>,
99
)*],)*) => {
10-
$(
11-
#[derive(Debug)]
12-
$(#[$docs])*
13-
pub enum $name {
14-
$(
15-
None($NoPin),
16-
)?
17-
18-
$(
19-
$(#[$attr])*
20-
$PX(gpio::$PX<Alternate<$A $(, $Otype)?>>),
21-
)*
22-
}
10+
$(
11+
#[derive(Debug)]
12+
$(#[$docs])*
13+
pub enum $name {
14+
$(
15+
None($NoPin),
16+
)?
2317

24-
impl crate::Sealed for $name { }
18+
$(
19+
$(#[$attr])*
20+
$PX(gpio::$PX<Alternate<$A $(, $Otype)?>>),
21+
)*
22+
}
2523

26-
#[allow(unreachable_patterns)]
27-
impl $name {
28-
pub fn is_high(&self) -> bool {
29-
!self.is_low()
30-
}
31-
pub fn is_low(&self) -> bool {
32-
match self {
33-
$(
34-
$(#[$attr])*
35-
Self::$PX(p) => p.is_low(),
36-
)*
37-
_ => false,
38-
}
24+
impl crate::Sealed for $name { }
25+
26+
#[allow(unreachable_patterns)]
27+
impl $name {
28+
pub fn is_high(&self) -> bool {
29+
!self.is_low()
30+
}
31+
pub fn is_low(&self) -> bool {
32+
match self {
33+
$(
34+
$(#[$attr])*
35+
Self::$PX(p) => p.is_low(),
36+
)*
37+
_ => false,
3938
}
4039
}
41-
#[allow(unreachable_patterns)]
42-
impl ExtiPin for $name {
43-
fn make_interrupt_source(&mut self, _syscfg: &mut SysCfg) {
44-
match self {
45-
$(
46-
$(#[$attr])*
47-
Self::$PX(p) => p.make_interrupt_source(_syscfg),
48-
)*
49-
_ => {},
50-
}
51-
40+
}
41+
#[allow(unreachable_patterns)]
42+
impl ExtiPin for $name {
43+
fn make_interrupt_source(&mut self, _syscfg: &mut SysCfg) {
44+
match self {
45+
$(
46+
$(#[$attr])*
47+
Self::$PX(p) => p.make_interrupt_source(_syscfg),
48+
)*
49+
_ => {},
5250
}
5351

54-
fn trigger_on_edge(&mut self, _exti: &mut EXTI, _level: Edge) {
55-
match self {
56-
$(
57-
$(#[$attr])*
58-
Self::$PX(p) => p.trigger_on_edge(_exti, _level),
59-
)*
60-
_ => {},
61-
}
52+
}
53+
54+
fn trigger_on_edge(&mut self, _exti: &mut EXTI, _level: Edge) {
55+
match self {
56+
$(
57+
$(#[$attr])*
58+
Self::$PX(p) => p.trigger_on_edge(_exti, _level),
59+
)*
60+
_ => {},
6261
}
62+
}
6363

64-
fn enable_interrupt(&mut self, _exti: &mut EXTI) {
65-
match self {
66-
$(
67-
$(#[$attr])*
68-
Self::$PX(p) => p.enable_interrupt(_exti),
69-
)*
70-
_ => {},
71-
}
64+
fn enable_interrupt(&mut self, _exti: &mut EXTI) {
65+
match self {
66+
$(
67+
$(#[$attr])*
68+
Self::$PX(p) => p.enable_interrupt(_exti),
69+
)*
70+
_ => {},
7271
}
73-
fn disable_interrupt(&mut self, _exti: &mut EXTI) {
74-
match self {
75-
$(
76-
$(#[$attr])*
77-
Self::$PX(p) => p.disable_interrupt(_exti),
78-
)*
79-
_ => {},
80-
}
72+
}
73+
fn disable_interrupt(&mut self, _exti: &mut EXTI) {
74+
match self {
75+
$(
76+
$(#[$attr])*
77+
Self::$PX(p) => p.disable_interrupt(_exti),
78+
)*
79+
_ => {},
8180
}
82-
fn clear_interrupt_pending_bit(&mut self) {
83-
match self {
84-
$(
85-
$(#[$attr])*
86-
Self::$PX(p) => p.clear_interrupt_pending_bit(),
87-
)*
88-
_ => {},
89-
}
81+
}
82+
fn clear_interrupt_pending_bit(&mut self) {
83+
match self {
84+
$(
85+
$(#[$attr])*
86+
Self::$PX(p) => p.clear_interrupt_pending_bit(),
87+
)*
88+
_ => {},
9089
}
91-
fn check_interrupt(&self) -> bool {
92-
match self {
93-
$(
94-
$(#[$attr])*
95-
Self::$PX(p) => p.check_interrupt(),
96-
)*
97-
_ => false,
98-
}
90+
}
91+
fn check_interrupt(&self) -> bool {
92+
match self {
93+
$(
94+
$(#[$attr])*
95+
Self::$PX(p) => p.check_interrupt(),
96+
)*
97+
_ => false,
9998
}
10099
}
100+
}
101101

102-
$(
103-
impl From<$NoPin> for $name {
104-
fn from(p: $NoPin) -> Self {
105-
Self::None(p)
106-
}
102+
$(
103+
impl From<$NoPin> for $name {
104+
fn from(p: $NoPin) -> Self {
105+
Self::None(p)
107106
}
107+
}
108108

109-
#[allow(irrefutable_let_patterns)]
110-
impl TryFrom<$name> for $NoPin {
111-
type Error = ();
109+
#[allow(irrefutable_let_patterns)]
110+
impl TryFrom<$name> for $NoPin {
111+
type Error = ();
112112

113-
fn try_from(a: $name) -> Result<Self, Self::Error> {
114-
if let $name::None(p) = a {
115-
Ok(p)
116-
} else {
117-
Err(())
118-
}
113+
fn try_from(a: $name) -> Result<Self, Self::Error> {
114+
if let $name::None(p) = a {
115+
Ok(p)
116+
} else {
117+
Err(())
119118
}
120119
}
121-
)?
120+
}
121+
)?
122122

123-
$(
124-
$(#[$attr])*
125-
impl From<gpio::$PX> for $name {
126-
fn from(p: gpio::$PX) -> Self {
127-
Self::$PX(p.into_mode())
128-
}
123+
$(
124+
$(#[$attr])*
125+
impl From<gpio::$PX> for $name {
126+
fn from(p: gpio::$PX) -> Self {
127+
Self::$PX(p.into_mode())
129128
}
129+
}
130130

131-
$(#[$attr])*
132-
impl From<gpio::$PX<Alternate<$A $(, $Otype)?>>> for $name {
133-
fn from(p: gpio::$PX<Alternate<$A $(, $Otype)?>>) -> Self {
134-
Self::$PX(p)
135-
}
131+
$(#[$attr])*
132+
impl From<gpio::$PX<Alternate<$A $(, $Otype)?>>> for $name {
133+
fn from(p: gpio::$PX<Alternate<$A $(, $Otype)?>>) -> Self {
134+
Self::$PX(p)
136135
}
136+
}
137137

138-
$(#[$attr])*
139-
#[allow(irrefutable_let_patterns)]
140-
impl<MODE: PinMode> TryFrom<$name> for gpio::$PX<MODE> {
141-
type Error = ();
142-
143-
fn try_from(a: $name) -> Result<Self, Self::Error> {
144-
if let $name::$PX(p) = a {
145-
Ok(p.into_mode())
146-
} else {
147-
Err(())
148-
}
138+
$(#[$attr])*
139+
#[allow(irrefutable_let_patterns)]
140+
impl<MODE: PinMode> TryFrom<$name> for gpio::$PX<MODE> {
141+
type Error = ();
142+
143+
fn try_from(a: $name) -> Result<Self, Self::Error> {
144+
if let $name::$PX(p) = a {
145+
Ok(p.into_mode())
146+
} else {
147+
Err(())
149148
}
150149
}
151-
)*
150+
}
152151
)*
152+
)*
153153
};
154154
}
155155

src/serial.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl<USART: Instance> Rx<USART, u8> {
866866
fn read(&mut self) -> nb::Result<u8, Error> {
867867
// Delegate to the Read<u16> implementation, then truncate to 8 bits
868868
unsafe {
869-
(&mut *(self as *mut Self as *mut Rx<USART, u16>))
869+
(*(self as *mut Self as *mut Rx<USART, u16>))
870870
.read()
871871
.map(|word16| word16 as u8)
872872
}
@@ -907,12 +907,12 @@ impl<USART: Instance> Rx<USART, u16> {
907907
impl<USART: Instance> Tx<USART, u8> {
908908
fn write(&mut self, word: u8) -> nb::Result<(), Error> {
909909
// Delegate to u16 version
910-
unsafe { (&mut *(self as *mut Self as *mut Tx<USART, u16>)).write(u16::from(word)) }
910+
unsafe { (*(self as *mut Self as *mut Tx<USART, u16>)).write(u16::from(word)) }
911911
}
912912

913913
fn flush(&mut self) -> nb::Result<(), Error> {
914914
// Delegate to u16 version
915-
unsafe { (&mut *(self as *mut Self as *mut Tx<USART, u16>)).flush() }
915+
unsafe { (*(self as *mut Self as *mut Tx<USART, u16>)).flush() }
916916
}
917917

918918
fn bwrite_all(&mut self, bytes: &[u8]) -> Result<(), Error> {

0 commit comments

Comments
 (0)