X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/7b7b572052951018da4d6d0f5753d627836236ad..eca97054b9edb6258d1392240d12b0772a10f20d:/m17core/src/kiss.rs diff --git a/m17core/src/kiss.rs b/m17core/src/kiss.rs index ec30296..4ada6dc 100644 --- a/m17core/src/kiss.rs +++ b/m17core/src/kiss.rs @@ -215,15 +215,13 @@ impl KissFrame { .iter() .enumerate() .skip_while(|(_, b)| **b == FEND) - .skip(1) - .next() + .nth(1) .ok_or(KissError::MalformedKissFrame)? .0; let end = self.data[start..] .iter() .enumerate() - .skip_while(|(_, b)| **b != FEND) - .next() + .find(|(_, b)| **b == FEND) .ok_or(KissError::MalformedKissFrame)? .0 + start; @@ -237,13 +235,11 @@ impl KissFrame { /// Return the header byte of the KISS frame, skipping over 0 or more prepended FENDs. fn header_byte(&self) -> Result { - Ok(self - .data + self.data .iter() - .skip_while(|b| **b == FEND) - .next() + .find(|b| **b != FEND) .cloned() - .ok_or(KissError::MalformedKissFrame)?) + .ok_or(KissError::MalformedKissFrame) } } @@ -393,6 +389,12 @@ impl KissBuffer { } } +impl Default for KissBuffer { + fn default() -> Self { + Self::new() + } +} + #[derive(Debug, PartialEq, Eq, Clone)] pub enum KissError { MalformedKissFrame,