Skip to content

Commit 7fe0e5a

Browse files
committed
Fix formatting and some build warnings.
1 parent bfe146e commit 7fe0e5a

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

benches/hex.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,25 @@ fn bench_decode(c: &mut Criterion) {
3535
c.bench_function("faster_hex_decode", move |b| {
3636
let hex = faster_hex::hex_string(DATA).unwrap();
3737
let len = DATA.len();
38-
b.iter(|| {
39-
let mut dst = Vec::with_capacity(len);
40-
dst.resize(len, 0);
41-
faster_hex::hex_decode(hex.as_bytes(), &mut dst).unwrap();
42-
dst
43-
})
38+
let mut dst = vec![0; len];
39+
40+
b.iter(|| faster_hex::hex_decode(hex.as_bytes(), &mut dst).unwrap())
4441
});
4542

4643
c.bench_function("faster_hex_decode_unchecked", |b| {
4744
let hex = faster_hex::hex_string(DATA).unwrap();
4845
let len = DATA.len();
49-
b.iter(|| {
50-
let mut dst = Vec::with_capacity(len);
51-
dst.resize(len, 0);
52-
faster_hex::hex_decode_unchecked(hex.as_bytes(), &mut dst);
53-
dst
54-
})
46+
let mut dst = vec![0; len];
47+
48+
b.iter(|| faster_hex::hex_decode_unchecked(hex.as_bytes(), &mut dst))
5549
});
5650

5751
c.bench_function("faster_hex_decode_fallback", |b| {
5852
let hex = faster_hex::hex_string(DATA).unwrap();
5953
let len = DATA.len();
60-
b.iter(|| {
61-
let mut dst = Vec::with_capacity(len);
62-
dst.resize(len, 0);
63-
faster_hex::hex_decode_fallback(hex.as_bytes(), &mut dst);
64-
dst
65-
})
54+
let mut dst = vec![0; len];
55+
56+
b.iter(|| faster_hex::hex_decode_fallback(hex.as_bytes(), &mut dst))
6657
});
6758
}
6859

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ impl<T: AsRef<[u8]>> ToHex for T {
151151
/// # Example
152152
///
153153
/// ```
154-
/// use hex::FromHex;
155154
/// use core::str;
155+
/// use hex::FromHex;
156156
///
157157
/// let buffer = <[u8; 12]>::from_hex("48656c6c6f20776f726c6421")?;
158158
/// let string = str::from_utf8(&buffer).expect("invalid buffer length");
@@ -392,9 +392,7 @@ mod test {
392392
#[test]
393393
#[cfg(feature = "alloc")]
394394
fn test_gen_iter() {
395-
let mut result = Vec::new();
396-
result.push((0, 1));
397-
result.push((2, 3));
395+
let result = vec![(0, 1), (2, 3)];
398396

399397
assert_eq!(generate_iter(5).collect::<Vec<_>>(), result);
400398
}

src/serde.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Hex encoding with `serde`.
2-
//!
32
#[cfg_attr(
43
all(feature = "alloc", feature = "serde"),
54
doc = r##"
@@ -49,7 +48,8 @@ where
4948
///
5049
/// Lowercase characters are used (e.g. `f9b4ca`). The resulting string's length
5150
/// is always even, each byte in data is always encoded using two hex digits.
52-
/// Thus, the resulting string contains exactly twice as many bytes as the input data.
51+
/// Thus, the resulting string contains exactly twice as many bytes as the input
52+
/// data.
5353
#[cfg(feature = "alloc")]
5454
pub fn serialize<S, T>(data: T, serializer: S) -> Result<S::Ok, S::Error>
5555
where

tests/serde.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg(all(feature = "serde", feature = "alloc"))]
2+
#![allow(clippy::blacklisted_name)]
23

34
use serde::{Deserialize, Serialize};
45

tests/version-number.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(non_fmt_panic)]
2+
13
#[test]
24
fn test_readme_deps() {
35
version_sync::assert_markdown_deps_updated!("README.md");

0 commit comments

Comments
 (0)