Skip to content

Commit 643cd6c

Browse files
committed
chore: fix lints
1 parent def3dfe commit 643cd6c

File tree

9 files changed

+19
-27
lines changed

9 files changed

+19
-27
lines changed

embedded-cli/src/arguments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a> ArgList<'a> {
4646
}
4747
}
4848

49-
impl<'a> PartialEq for ArgList<'a> {
49+
impl PartialEq for ArgList<'_> {
5050
fn eq(&self, other: &Self) -> bool {
5151
self.args().eq(other.args())
5252
}

embedded-cli/src/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<const SIZE: usize> Buffer for [u8; SIZE] {
2727
}
2828
}
2929

30-
impl<'a> Buffer for &'a mut [u8] {
30+
impl Buffer for &mut [u8] {
3131
fn as_slice(&self) -> &[u8] {
3232
self
3333
}

embedded-cli/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ where
5656
}
5757
}
5858

59-
impl<'a, W, E> Debug for CliHandle<'a, W, E>
59+
impl<W, E> Debug for CliHandle<'_, W, E>
6060
where
6161
W: Write<Error = E>,
6262
E: embedded_io::Error,

embedded-cli/src/command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ impl<'a> RawCommand<'a> {
9292
}
9393
}
9494

95-
impl<'a> Autocomplete for RawCommand<'a> {
95+
impl Autocomplete for RawCommand<'_> {
9696
#[cfg(feature = "autocomplete")]
9797
fn autocomplete(_: Request<'_>, _: &mut Autocompletion<'_>) {
9898
// noop
9999
}
100100
}
101101

102-
impl<'a> Help for RawCommand<'a> {
102+
impl Help for RawCommand<'_> {
103103
#[cfg(feature = "help")]
104104
fn command_count() -> usize {
105105
0
@@ -156,7 +156,7 @@ mod tests {
156156
assert_eq!(
157157
RawCommand::from_tokens(&input_tokens).unwrap(),
158158
RawCommand {
159-
name: name,
159+
name,
160160
args: ArgList::new(arg_tokens)
161161
}
162162
);

embedded-cli/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a> From<FromArgumentError<'a>> for ParseError<'a> {
5151
}
5252
}
5353

54-
impl<'a, E: embedded_io::Error> From<E> for ProcessError<'a, E> {
54+
impl<E: embedded_io::Error> From<E> for ProcessError<'_, E> {
5555
fn from(value: E) -> Self {
5656
Self::WriteError(value)
5757
}

embedded-cli/src/utils.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ pub fn encode_utf8(ch: char, buf: &mut [u8]) -> &str {
123123

124124
buf[0] = code as u8 | first_b_mask;
125125

126-
unsafe {
127-
return core::str::from_utf8_unchecked(&buf[..len]);
128-
}
126+
unsafe { core::str::from_utf8_unchecked(&buf[..len]) }
129127
}
130128

131129
pub fn trim_start(input: &str) -> &str {

embedded-cli/src/writer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub struct Writer<'a, W: Write<Error = E>, E: Error> {
1111
writer: &'a mut W,
1212
}
1313

14-
impl<'a, W: Write<Error = E>, E: Error> Debug for Writer<'a, W, E> {
14+
impl<W: Write<Error = E>, E: Error> Debug for Writer<'_, W, E> {
1515
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1616
f.debug_struct("Writer")
1717
.field("last_bytes", &self.last_bytes)
@@ -98,15 +98,15 @@ impl<'a, W: Write<Error = E>, E: Error> Writer<'a, W, E> {
9898
}
9999
}
100100

101-
impl<'a, W: Write<Error = E>, E: Error> uWrite for Writer<'a, W, E> {
101+
impl<W: Write<Error = E>, E: Error> uWrite for Writer<'_, W, E> {
102102
type Error = E;
103103

104104
fn write_str(&mut self, s: &str) -> Result<(), E> {
105105
self.write_str(s)
106106
}
107107
}
108108

109-
impl<'a, W: Write<Error = E>, E: Error> core::fmt::Write for Writer<'a, W, E> {
109+
impl<W: Write<Error = E>, E: Error> core::fmt::Write for Writer<'_, W, E> {
110110
fn write_str(&mut self, s: &str) -> core::fmt::Result {
111111
self.write_str(s).map_err(|_| core::fmt::Error)?;
112112
Ok(())

embedded-cli/tests/cli/terminal.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Terminal {
6868
};
6969

7070
if let Some(normal) = normal {
71-
for c in normal.chars().into_iter() {
71+
for c in normal.chars() {
7272
match c {
7373
'\r' => {
7474
cursor = 0;
@@ -80,16 +80,13 @@ impl Terminal {
8080
c if c >= ' ' => {
8181
let current = output.last_mut().unwrap();
8282
if current.chars().count() > cursor {
83-
current
84-
.remove(current.char_indices().skip(cursor).next().unwrap().0);
83+
current.remove(current.char_indices().nth(cursor).unwrap().0);
8584
} else {
8685
while current.chars().count() < cursor {
8786
current.push(' ');
8887
}
8988
}
90-
if let Some((insert_pos, _)) =
91-
current.char_indices().skip(cursor).next()
92-
{
89+
if let Some((insert_pos, _)) = current.char_indices().nth(cursor) {
9390
current.insert(insert_pos, c);
9491
} else {
9592
current.push(c);
@@ -110,21 +107,18 @@ impl Terminal {
110107
}
111108
// cursor backward
112109
"\x1B[D" => {
113-
if cursor > 0 {
114-
cursor -= 1;
115-
}
110+
cursor = cursor.saturating_sub(1);
116111
}
117112
// delete char
118113
"\x1B[P" => {
119114
if current.chars().count() > cursor {
120-
current.remove(current.char_indices().skip(cursor).next().unwrap().0);
115+
current.remove(current.char_indices().nth(cursor).unwrap().0);
121116
}
122117
}
123118
// insert char
124119
"\x1B[@" => {
125120
if current.chars().count() > cursor {
126-
current
127-
.insert(current.char_indices().skip(cursor).next().unwrap().0, ' ');
121+
current.insert(current.char_indices().nth(cursor).unwrap().0, ' ');
128122
}
129123
}
130124
// clear whole line

embedded-cli/tests/cli/wrapper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ macro_rules! impl_convert {
5555
}
5656
}
5757

58-
impl crate::wrapper::CommandConvert for $to_ty {
58+
impl $crate::wrapper::CommandConvert for $to_ty {
5959
fn convert(
6060
cmd: embedded_cli::command::RawCommand<'_>,
6161
) -> Result<Self, crate::wrapper::ParseError> {
@@ -153,7 +153,7 @@ impl<'a> From<CliParseError<'a>> for ParseError {
153153
Self::UnexpectedLongOption { name: name.into() }
154154
}
155155
CliParseError::UnexpectedShortOption { name } => {
156-
Self::UnexpectedShortOption { name: name.into() }
156+
Self::UnexpectedShortOption { name: name }
157157
}
158158
CliParseError::UnknownCommand => Self::UnknownCommand,
159159
_ => Self::Other,

0 commit comments

Comments
 (0)