Skip to content

Commit

Permalink
Fix formatting and some build warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
KokaKiwi committed Mar 3, 2021
1 parent bfe146e commit 7fe0e5a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
27 changes: 9 additions & 18 deletions benches/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,25 @@ fn bench_decode(c: &mut Criterion) {
c.bench_function("faster_hex_decode", move |b| {
let hex = faster_hex::hex_string(DATA).unwrap();
let len = DATA.len();
b.iter(|| {
let mut dst = Vec::with_capacity(len);
dst.resize(len, 0);
faster_hex::hex_decode(hex.as_bytes(), &mut dst).unwrap();
dst
})
let mut dst = vec![0; len];

b.iter(|| faster_hex::hex_decode(hex.as_bytes(), &mut dst).unwrap())
});

c.bench_function("faster_hex_decode_unchecked", |b| {
let hex = faster_hex::hex_string(DATA).unwrap();
let len = DATA.len();
b.iter(|| {
let mut dst = Vec::with_capacity(len);
dst.resize(len, 0);
faster_hex::hex_decode_unchecked(hex.as_bytes(), &mut dst);
dst
})
let mut dst = vec![0; len];

b.iter(|| faster_hex::hex_decode_unchecked(hex.as_bytes(), &mut dst))
});

c.bench_function("faster_hex_decode_fallback", |b| {
let hex = faster_hex::hex_string(DATA).unwrap();
let len = DATA.len();
b.iter(|| {
let mut dst = Vec::with_capacity(len);
dst.resize(len, 0);
faster_hex::hex_decode_fallback(hex.as_bytes(), &mut dst);
dst
})
let mut dst = vec![0; len];

b.iter(|| faster_hex::hex_decode_fallback(hex.as_bytes(), &mut dst))
});
}

Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ impl<T: AsRef<[u8]>> ToHex for T {
/// # Example
///
/// ```
/// use hex::FromHex;
/// use core::str;
/// use hex::FromHex;
///
/// let buffer = <[u8; 12]>::from_hex("48656c6c6f20776f726c6421")?;
/// let string = str::from_utf8(&buffer).expect("invalid buffer length");
Expand Down Expand Up @@ -392,9 +392,7 @@ mod test {
#[test]
#[cfg(feature = "alloc")]
fn test_gen_iter() {
let mut result = Vec::new();
result.push((0, 1));
result.push((2, 3));
let result = vec![(0, 1), (2, 3)];

assert_eq!(generate_iter(5).collect::<Vec<_>>(), result);
}
Expand Down
4 changes: 2 additions & 2 deletions src/serde.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Hex encoding with `serde`.
//!
#[cfg_attr(
all(feature = "alloc", feature = "serde"),
doc = r##"
Expand Down Expand Up @@ -49,7 +48,8 @@ where
///
/// Lowercase characters are used (e.g. `f9b4ca`). The resulting string's length
/// is always even, each byte in data is always encoded using two hex digits.
/// Thus, the resulting string contains exactly twice as many bytes as the input data.
/// Thus, the resulting string contains exactly twice as many bytes as the input
/// data.
#[cfg(feature = "alloc")]
pub fn serialize<S, T>(data: T, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
1 change: 1 addition & 0 deletions tests/serde.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg(all(feature = "serde", feature = "alloc"))]
#![allow(clippy::blacklisted_name)]

use serde::{Deserialize, Serialize};

Expand Down
2 changes: 2 additions & 0 deletions tests/version-number.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(non_fmt_panic)]

#[test]
fn test_readme_deps() {
version_sync::assert_markdown_deps_updated!("README.md");
Expand Down

0 comments on commit 7fe0e5a

Please sign in to comment.