From b0a9120c36867de472c4a262eeb5fd7cefae711b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 21 Feb 2024 14:00:31 +1100 Subject: [PATCH] REMOVE ME: Run formatter --- examples/hexy.rs | 7 ++---- examples/wrap_array_display_hex_trait.rs | 4 +--- fuzz/fuzz_targets/hex.rs | 2 +- src/error.rs | 6 ++--- src/iter.rs | 30 ++++++++++-------------- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/examples/hexy.rs b/examples/hexy.rs index 5b78de6..93f9ee4 100644 --- a/examples/hexy.rs +++ b/examples/hexy.rs @@ -6,9 +6,7 @@ use std::fmt; use std::str::FromStr; -use hex_conservative::{ - fmt_hex_exact, Case, DisplayHex, FromHex, HexToArrayError, -}; +use hex_conservative::{fmt_hex_exact, Case, DisplayHex, FromHex, HexToArrayError}; fn main() { let s = "deadbeefcafebabedeadbeefcafebabedeadbeefcafebabedeadbeefcafebabe"; @@ -74,8 +72,7 @@ impl fmt::UpperHex for Hexy { impl FromHex for Hexy { type Error = HexToArrayError; - fn from_hex(s: &str) -> Result - { + fn from_hex(s: &str) -> Result { // Errors if the input is invalid let a = <[u8; 32] as FromHex>::from_hex(s)?; Ok(Hexy { data: a }) diff --git a/examples/wrap_array_display_hex_trait.rs b/examples/wrap_array_display_hex_trait.rs index 5ff51e5..a635005 100644 --- a/examples/wrap_array_display_hex_trait.rs +++ b/examples/wrap_array_display_hex_trait.rs @@ -47,9 +47,7 @@ pub struct Wrap([u8; 32]); impl FromHex for Wrap { type Error = HexToArrayError; - fn from_hex(s: &str) -> Result { - Ok(Self(FromHex::from_hex(s)?)) - } + fn from_hex(s: &str) -> Result { Ok(Self(FromHex::from_hex(s)?)) } } /// Use `DisplayArray` to display the `Wrap` type. diff --git a/fuzz/fuzz_targets/hex.rs b/fuzz/fuzz_targets/hex.rs index 04e17f7..29e9b18 100644 --- a/fuzz/fuzz_targets/hex.rs +++ b/fuzz/fuzz_targets/hex.rs @@ -1,4 +1,4 @@ -use hex::{FromHex, DisplayHex}; +use hex::{DisplayHex, FromHex}; use honggfuzz::fuzz; const LEN: usize = 32; // Arbitrary amount of data. diff --git a/src/error.rs b/src/error.rs index 9788126..6bb88f4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -117,10 +117,8 @@ impl fmt::Display for HexToArrayError { use HexToArrayError::*; match *self { - InvalidChar(ref e) => - crate::write_err!(f, "failed to parse hex digit"; e), - InvalidLength(ref e) => - write_err!(f, "failed to parse hex"; e), + InvalidChar(ref e) => crate::write_err!(f, "failed to parse hex digit"; e), + InvalidLength(ref e) => write_err!(f, "failed to parse hex"; e), } } } diff --git a/src/iter.rs b/src/iter.rs index 2fcb0f5..d123691 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -17,7 +17,7 @@ use crate::error::InvalidCharError; pub use crate::error::{HexToBytesError, OddLengthStringError}; /// Iterator yielding bytes decoded from an iterator of pairs of hex digits. -pub struct HexToBytesIter> { +pub struct HexToBytesIter> { iter: T, } @@ -41,15 +41,13 @@ impl<'a> HexToBytesIter> { } } -impl> HexToBytesIter { +impl> HexToBytesIter { /// Constructs a custom hex decoding iterator from another iterator. #[inline] - pub fn from_pairs(iter: T) -> Self { - Self { iter } - } + pub fn from_pairs(iter: T) -> Self { Self { iter } } } -impl> Iterator for HexToBytesIter { +impl> Iterator for HexToBytesIter { type Item = Result; #[inline] @@ -71,7 +69,7 @@ impl> Iterator for HexToBytesIter { } } -impl + DoubleEndedIterator> DoubleEndedIterator for HexToBytesIter { +impl + DoubleEndedIterator> DoubleEndedIterator for HexToBytesIter { #[inline] fn next_back(&mut self) -> Option { let [hi, lo] = self.iter.next_back()?; @@ -85,12 +83,12 @@ impl + DoubleEndedIterator> DoubleEndedIterator for He } } -impl + ExactSizeIterator> ExactSizeIterator for HexToBytesIter { } +impl + ExactSizeIterator> ExactSizeIterator for HexToBytesIter {} -impl + FusedIterator> FusedIterator for HexToBytesIter {} +impl + FusedIterator> FusedIterator for HexToBytesIter {} #[cfg(any(feature = "std", feature = "core2"))] -impl + FusedIterator> io::Read for HexToBytesIter { +impl + FusedIterator> io::Read for HexToBytesIter { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { let mut bytes_read = 0usize; @@ -120,9 +118,7 @@ pub struct HexDigitsIter<'a> { impl<'a> HexDigitsIter<'a> { #[inline] - fn new_unchecked(digits: &'a [u8]) -> Self { - Self { iter: digits.chunks_exact(2) } - } + fn new_unchecked(digits: &'a [u8]) -> Self { Self { iter: digits.chunks_exact(2) } } } impl<'a> Iterator for HexDigitsIter<'a> { @@ -134,9 +130,7 @@ impl<'a> Iterator for HexDigitsIter<'a> { } #[inline] - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() - } + fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } #[inline] fn nth(&mut self, n: usize) -> Option { @@ -156,9 +150,9 @@ impl<'a> DoubleEndedIterator for HexDigitsIter<'a> { } } -impl<'a> ExactSizeIterator for HexDigitsIter<'a> { } +impl<'a> ExactSizeIterator for HexDigitsIter<'a> {} -impl<'a> core::iter::FusedIterator for HexDigitsIter<'a> { } +impl<'a> core::iter::FusedIterator for HexDigitsIter<'a> {} /// `hi` and `lo` are bytes representing hex characters. fn hex_chars_to_byte(hi: u8, lo: u8) -> Result {