diff --git a/src/codec.rs b/src/codec.rs index b91bcdf..6e85335 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -53,12 +53,14 @@ impl ClientCodec { } if self.escape_count == 3 { self.escape_count = 0; - buf.write_all(&frame[start..idx]).await?; + buf.write_all(frame.get(start..idx).unwrap_or_default()) + .await?; buf.write_all(b".").await?; start = idx; } } - buf.write_all(&frame[start..]).await?; + buf.write_all(frame.get(start..).unwrap_or_default()) + .await?; Ok(()) } } diff --git a/src/extension.rs b/src/extension.rs index 3c811e8..d3969fd 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -144,7 +144,7 @@ impl ServerInfo { features.insert(Extension::StartTls); } Some("AUTH") => { - for &mechanism in &split[1..] { + for &mechanism in split.iter().skip(1) { match mechanism { "PLAIN" => { features.insert(Extension::Authentication(Mechanism::Plain)); diff --git a/src/lib.rs b/src/lib.rs index d2225b6..ed5519a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,11 @@ unused_import_braces, missing_debug_implementations, missing_docs, - clippy::explicit_iter_loop + clippy::explicit_iter_loop, + clippy::unwrap_used, + clippy::expect_used, + clippy::indexing_slicing, + clippy::string_slice )] #[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))] diff --git a/src/util.rs b/src/util.rs index c0c55fc..f4d01a1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -10,22 +10,14 @@ pub struct XText<'a>(pub &'a str); impl Display for XText<'_> { fn fmt(&self, f: &mut Formatter) -> FmtResult { - let mut rest = self.0; - while let Some(idx) = rest.find(|c| c < '!' || c == '+' || c == '=') { - let (start, end) = rest.split_at(idx); - f.write_str(start)?; - - let mut end_iter = end.char_indices(); - let (_, c) = end_iter.next().expect("char"); - write!(f, "+{:X}", c as u8)?; - - if let Some((idx, _)) = end_iter.next() { - rest = &end[idx..]; + for c in self.0.chars() { + if c < '!' || c == '+' || c == '=' { + write!(f, "+{:X}", c as u8)?; } else { - rest = ""; + write!(f, "{c}")?; } } - f.write_str(rest) + Ok(()) } }