Skip to content

Commit

Permalink
Trivial changes suggested by clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
comex committed Dec 27, 2024
1 parent db64b0d commit c495f8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ impl<'a> Shlex<'a> {
return None;
},
'\\' => if let Some(ch2) = self.next_char() {
if ch2 != '\n' as u8 { result.push(ch2); }
if ch2 != b'\n' { result.push(ch2); }
} else {
self.had_error = true;
return None;
},
' ' | '\t' | '\n' => { break; },
_ => { result.push(ch as u8); },
_ => { result.push(ch); },
}
if let Some(ch2) = self.next_char() { ch = ch2; } else { break; }
}
Expand All @@ -95,7 +95,7 @@ impl<'a> Shlex<'a> {
// \<newline> => nothing
'\n' => {},
// \x => =x
_ => { result.push('\\' as u8); result.push(ch3); }
_ => { result.push(b'\\'); result.push(ch3); }
}
} else {
return Err(());
Expand Down Expand Up @@ -130,7 +130,7 @@ impl<'a> Shlex<'a> {
}
}

impl<'a> Iterator for Shlex<'a> {
impl Iterator for Shlex<'_> {
type Item = Vec<u8>;
fn next(&mut self) -> Option<Self::Item> {
if let Some(mut ch) = self.next_char() {
Expand Down Expand Up @@ -427,7 +427,7 @@ fn append_quoted_chunk(out: &mut Vec<u8>, cur_chunk: &[u8], strategy: QuotingStr
QuotingStrategy::DoubleQuoted => {
out.reserve(cur_chunk.len() + 2);
out.push(b'"');
for &c in cur_chunk.into_iter() {
for &c in cur_chunk.iter() {
if let b'$' | b'`' | b'"' | b'\\' = c {
// Add a preceding backslash.
// Note: We shouldn't actually get here for $ and ` because they don't pass
Expand Down Expand Up @@ -511,7 +511,7 @@ fn test_invalid_utf8() {
}

#[cfg(test)]
static SPLIT_TEST_ITEMS: &'static [(&'static [u8], Option<&'static [&'static [u8]]>)] = &[
static SPLIT_TEST_ITEMS: &[(&[u8], Option<&[&[u8]]>)] = &[
(b"foo$baz", Some(&[b"foo$baz"])),
(b"foo baz", Some(&[b"foo", b"baz"])),
(b"foo\"bar\"baz", Some(&[b"foobarbaz"])),
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'a> Shlex<'a> {
}
}

impl<'a> Iterator for Shlex<'a> {
impl Iterator for Shlex<'_> {
type Item = String;
fn next(&mut self) -> Option<String> {
self.0.next().map(|byte_word| {
Expand All @@ -81,7 +81,7 @@ impl<'a> core::ops::Deref for Shlex<'a> {
}
}

impl<'a> core::ops::DerefMut for Shlex<'a> {
impl core::ops::DerefMut for Shlex<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
Expand Down Expand Up @@ -243,7 +243,7 @@ pub fn try_quote(in_str: &str) -> Result<Cow<str>, QuoteError> {
}

#[cfg(test)]
static SPLIT_TEST_ITEMS: &'static [(&'static str, Option<&'static [&'static str]>)] = &[
static SPLIT_TEST_ITEMS: &[(&str, Option<&[&str]>)] = &[
("foo$baz", Some(&["foo$baz"])),
("foo baz", Some(&["foo", "baz"])),
("foo\"bar\"baz", Some(&["foobarbaz"])),
Expand Down

0 comments on commit c495f8a

Please sign in to comment.