Skip to content

Commit e8efb6c

Browse files
committed
chore: fix clippy lints
Signed-off-by: Nathaniel McCallum <[email protected]>
1 parent 2235c93 commit e8efb6c

File tree

11 files changed

+61
-63
lines changed

11 files changed

+61
-63
lines changed

ciborium-ll/src/hdr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ impl From<Header> for Title {
122122
fn from(header: Header) -> Self {
123123
let int = |i: u64| match i {
124124
x if x <= 23 => Minor::This(i as u8),
125-
x if x <= core::u8::MAX as u64 => Minor::Next1([i as u8]),
126-
x if x <= core::u16::MAX as u64 => Minor::Next2((i as u16).to_be_bytes()),
127-
x if x <= core::u32::MAX as u64 => Minor::Next4((i as u32).to_be_bytes()),
125+
x if x <= u8::MAX as u64 => Minor::Next1([i as u8]),
126+
x if x <= u16::MAX as u64 => Minor::Next2((i as u16).to_be_bytes()),
127+
x if x <= u32::MAX as u64 => Minor::Next4((i as u32).to_be_bytes()),
128128
x => Minor::Next8(x.to_be_bytes()),
129129
};
130130

ciborium-ll/src/lib.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ mod tests {
229229
#[allow(clippy::excessive_precision)]
230230
#[test]
231231
fn leaf() {
232-
use core::f64::{INFINITY, NAN};
233-
234232
let data = &[
235233
(Header::Positive(0), "00", true),
236234
(Header::Positive(1), "01", true),
@@ -265,15 +263,15 @@ mod tests {
265263
(Header::Float(0.00006103515625), "f90400", true),
266264
(Header::Float(-4.0), "f9c400", true),
267265
(Header::Float(-4.1), "fbc010666666666666", true),
268-
(Header::Float(INFINITY), "f97c00", true),
269-
(Header::Float(NAN), "f97e00", true),
270-
(Header::Float(-INFINITY), "f9fc00", true),
271-
(Header::Float(INFINITY), "fa7f800000", false),
272-
(Header::Float(NAN), "fa7fc00000", false),
273-
(Header::Float(-INFINITY), "faff800000", false),
274-
(Header::Float(INFINITY), "fb7ff0000000000000", false),
275-
(Header::Float(NAN), "fb7ff8000000000000", false),
276-
(Header::Float(-INFINITY), "fbfff0000000000000", false),
266+
(Header::Float(f64::INFINITY), "f97c00", true),
267+
(Header::Float(f64::NAN), "f97e00", true),
268+
(Header::Float(-f64::INFINITY), "f9fc00", true),
269+
(Header::Float(f64::INFINITY), "fa7f800000", false),
270+
(Header::Float(f64::NAN), "fa7fc00000", false),
271+
(Header::Float(-f64::INFINITY), "faff800000", false),
272+
(Header::Float(f64::INFINITY), "fb7ff0000000000000", false),
273+
(Header::Float(f64::NAN), "fb7ff8000000000000", false),
274+
(Header::Float(-f64::INFINITY), "fbfff0000000000000", false),
277275
(Header::Simple(simple::FALSE), "f4", true),
278276
(Header::Simple(simple::TRUE), "f5", true),
279277
(Header::Simple(simple::NULL), "f6", true),

ciborium/src/de/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<T> From<ciborium_ll::Error<T>> for Error<T> {
5959
impl<T: Debug> Display for Error<T> {
6060
#[inline]
6161
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
62-
write!(f, "{:?}", self)
62+
write!(f, "{self:?}")
6363
}
6464
}
6565

ciborium/src/ser/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<T> From<T> for Error<T> {
2929
impl<T: Debug> Display for Error<T> {
3030
#[inline]
3131
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
32-
write!(f, "{:?}", self)
32+
write!(f, "{self:?}")
3333
}
3434
}
3535

ciborium/src/tag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub(crate) struct Error;
240240
impl core::fmt::Display for Error {
241241
#[inline]
242242
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
243-
write!(f, "{:?}", self)
243+
write!(f, "{self:?}")
244244
}
245245
}
246246

ciborium/src/value/de.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'de> de::Deserialize<'de> for Value {
177177

178178
struct Deserializer<T>(T);
179179

180-
impl<'a> Deserializer<&'a Value> {
180+
impl Deserializer<&Value> {
181181
fn integer<N>(&self, kind: &'static str) -> Result<N, Error>
182182
where
183183
N: TryFrom<u128>,
@@ -223,7 +223,7 @@ impl<'a> Deserializer<&'a Value> {
223223
}
224224
}
225225

226-
impl<'a, 'de> de::Deserializer<'de> for Deserializer<&'a Value> {
226+
impl<'de> de::Deserializer<'de> for Deserializer<&Value> {
227227
type Error = Error;
228228

229229
#[inline]
@@ -599,7 +599,7 @@ impl<'a, 'de> de::EnumAccess<'de> for Deserializer<&'a Value> {
599599
}
600600
}
601601

602-
impl<'a, 'de> de::VariantAccess<'de> for Deserializer<&'a Value> {
602+
impl<'de> de::VariantAccess<'de> for Deserializer<&Value> {
603603
type Error = Error;
604604

605605
#[inline]

ciborium/src/value/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub enum Error {
1111

1212
impl core::fmt::Display for Error {
1313
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
14-
write!(f, "{:?}", self)
14+
write!(f, "{self:?}")
1515
}
1616
}
1717

ciborium/tests/codec.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -202,30 +202,30 @@ macro_rules! map {
202202
case(-4.0f64, val!(-4.0f64), "f9c400", false, Float, None),
203203
case(-4.1f32, val!(-4.1f32), "fac0833333", false, Float, None), // Not In RFC
204204
case(-4.1f64, val!(-4.1f64), "fbc010666666666666", false, Float, None),
205-
case(core::f32::INFINITY, val!(core::f32::INFINITY), "f97c00", false, Float, None),
206-
case(core::f64::INFINITY, val!(core::f64::INFINITY), "f97c00", false, Float, None),
207-
case(core::f32::INFINITY, val!(core::f32::INFINITY), "fa7f800000", true, Float, None),
208-
case(core::f64::INFINITY, val!(core::f64::INFINITY), "fa7f800000", true, Float, None),
209-
case(core::f32::INFINITY, val!(core::f32::INFINITY), "fb7ff0000000000000", true, Float, None),
210-
case(core::f64::INFINITY, val!(core::f64::INFINITY), "fb7ff0000000000000", true, Float, None),
211-
case(-core::f32::INFINITY, val!(-core::f32::INFINITY), "f9fc00", false, Float, None),
212-
case(-core::f64::INFINITY, val!(-core::f64::INFINITY), "f9fc00", false, Float, None),
213-
case(-core::f32::INFINITY, val!(-core::f32::INFINITY), "faff800000", true, Float, None),
214-
case(-core::f64::INFINITY, val!(-core::f64::INFINITY), "faff800000", true, Float, None),
215-
case(-core::f32::INFINITY, val!(-core::f32::INFINITY), "fbfff0000000000000", true, Float, None),
216-
case(-core::f64::INFINITY, val!(-core::f64::INFINITY), "fbfff0000000000000", true, Float, None),
217-
case(core::f32::NAN, val!(core::f32::NAN), "f97e00", false, Float, None),
218-
case(core::f64::NAN, val!(core::f64::NAN), "f97e00", false, Float, None),
219-
case(core::f32::NAN, val!(core::f32::NAN), "fa7fc00000", true, Float, None),
220-
case(core::f64::NAN, val!(core::f64::NAN), "fa7fc00000", true, Float, None),
221-
case(core::f32::NAN, val!(core::f32::NAN), "fb7ff8000000000000", true, Float, None),
222-
case(core::f64::NAN, val!(core::f64::NAN), "fb7ff8000000000000", true, Float, None),
223-
case(-core::f32::NAN, val!(-core::f64::NAN), "f9fe00", false, Float, None), // Not In RFC
224-
case(-core::f64::NAN, val!(-core::f64::NAN), "f9fe00", false, Float, None), // Not In RFC
225-
case(-core::f32::NAN, val!(-core::f32::NAN), "faffc00000", true, Float, None), // Not In RFC
226-
case(-core::f64::NAN, val!(-core::f64::NAN), "faffc00000", true, Float, None), // Not In RFC
227-
case(-core::f32::NAN, val!(-core::f32::NAN), "fbfff8000000000000", true, Float, None), // Not In RFC
228-
case(-core::f64::NAN, val!(-core::f64::NAN), "fbfff8000000000000", true, Float, None), // Not In RFC
205+
case(f32::INFINITY, val!(f32::INFINITY), "f97c00", false, Float, None),
206+
case(f64::INFINITY, val!(f64::INFINITY), "f97c00", false, Float, None),
207+
case(f32::INFINITY, val!(f32::INFINITY), "fa7f800000", true, Float, None),
208+
case(f64::INFINITY, val!(f64::INFINITY), "fa7f800000", true, Float, None),
209+
case(f32::INFINITY, val!(f32::INFINITY), "fb7ff0000000000000", true, Float, None),
210+
case(f64::INFINITY, val!(f64::INFINITY), "fb7ff0000000000000", true, Float, None),
211+
case(-f32::INFINITY, val!(-f32::INFINITY), "f9fc00", false, Float, None),
212+
case(-f64::INFINITY, val!(-f64::INFINITY), "f9fc00", false, Float, None),
213+
case(-f32::INFINITY, val!(-f32::INFINITY), "faff800000", true, Float, None),
214+
case(-f64::INFINITY, val!(-f64::INFINITY), "faff800000", true, Float, None),
215+
case(-f32::INFINITY, val!(-f32::INFINITY), "fbfff0000000000000", true, Float, None),
216+
case(-f64::INFINITY, val!(-f64::INFINITY), "fbfff0000000000000", true, Float, None),
217+
case(f32::NAN, val!(f32::NAN), "f97e00", false, Float, None),
218+
case(f64::NAN, val!(f64::NAN), "f97e00", false, Float, None),
219+
case(f32::NAN, val!(f32::NAN), "fa7fc00000", true, Float, None),
220+
case(f64::NAN, val!(f64::NAN), "fa7fc00000", true, Float, None),
221+
case(f32::NAN, val!(f32::NAN), "fb7ff8000000000000", true, Float, None),
222+
case(f64::NAN, val!(f64::NAN), "fb7ff8000000000000", true, Float, None),
223+
case(-f32::NAN, val!(-f64::NAN), "f9fe00", false, Float, None), // Not In RFC
224+
case(-f64::NAN, val!(-f64::NAN), "f9fe00", false, Float, None), // Not In RFC
225+
case(-f32::NAN, val!(-f32::NAN), "faffc00000", true, Float, None), // Not In RFC
226+
case(-f64::NAN, val!(-f64::NAN), "faffc00000", true, Float, None), // Not In RFC
227+
case(-f32::NAN, val!(-f32::NAN), "fbfff8000000000000", true, Float, None), // Not In RFC
228+
case(-f64::NAN, val!(-f64::NAN), "fbfff8000000000000", true, Float, None), // Not In RFC
229229
case(false, val!(false), "f4", false, same, None),
230230
case(true, val!(true), "f5", false, same, None),
231231
case(Value::Null, Value::Null, "f6", false, same, None),
@@ -292,12 +292,12 @@ fn codec<'de, T: Serialize + Clone, V: Debug + PartialEq + DeserializeOwned, F:
292292
if !alternate {
293293
let mut encoded = Vec::new();
294294
into_writer(&input, &mut encoded).unwrap();
295-
eprintln!("{:x?} == {:x?}", bytes, encoded);
295+
eprintln!("{bytes:x?} == {encoded:x?}");
296296
assert_eq!(bytes, encoded);
297297

298298
let mut encoded = Vec::new();
299299
into_writer(&input, &mut encoded).unwrap();
300-
eprintln!("{:x?} == {:x?}", bytes, encoded);
300+
eprintln!("{bytes:x?} == {encoded:x?}");
301301
assert_eq!(bytes, encoded);
302302

303303
let encoded = Value::serialized(&input).unwrap();
@@ -307,7 +307,7 @@ fn codec<'de, T: Serialize + Clone, V: Debug + PartialEq + DeserializeOwned, F:
307307

308308
let decoded: V = from_reader(&bytes[..]).unwrap();
309309
let answer = equality(input.clone());
310-
eprintln!("{:x?} == {:x?}", answer, decoded);
310+
eprintln!("{answer:x?} == {decoded:x?}");
311311
assert_eq!(answer, decoded);
312312

313313
let decoded: Value = from_reader(&bytes[..]).unwrap();
@@ -325,7 +325,7 @@ fn codec<'de, T: Serialize + Clone, V: Debug + PartialEq + DeserializeOwned, F:
325325
} else {
326326
equality(input)
327327
};
328-
eprintln!("{:x?} == {:x?}", answer, decoded);
328+
eprintln!("{answer:x?} == {decoded:x?}");
329329
assert_eq!(answer, decoded);
330330
}
331331

ciborium/tests/fuzz.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ fn fuzz() {
5656

5757
let mut string = String::new();
5858
parent.read_to_string(&mut string).unwrap();
59-
eprint!("{}", string);
59+
eprint!("{string}");
6060

6161
let mut status = 0;
6262
assert_eq!(pid, unsafe { waitpid(pid, &mut status, 0) });
6363

64-
eprintln!("exit status: {:?}", status);
64+
eprintln!("exit status: {status:?}");
6565
assert_eq!(0, status);
6666
}
6767
}

ciborium/tests/recursion.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn array() {
1616
let bytes = [0x9f; 128 * 1024];
1717
match from_reader::<Value, _>(&bytes[..]).unwrap_err() {
1818
Error::RecursionLimitExceeded => (),
19-
e => panic!("incorrect error: {:?}", e),
19+
e => panic!("incorrect error: {e:?}"),
2020
}
2121
}
2222

@@ -25,7 +25,7 @@ fn map() {
2525
let bytes = [0xbf; 128 * 1024];
2626
match from_reader::<Value, _>(&bytes[..]).unwrap_err() {
2727
Error::RecursionLimitExceeded => (),
28-
e => panic!("incorrect error: {:?}", e),
28+
e => panic!("incorrect error: {e:?}"),
2929
}
3030
}
3131

@@ -34,7 +34,7 @@ fn bytes() {
3434
let bytes = [0x5f; 128 * 1024];
3535
match from_reader::<Value, _>(&bytes[..]).unwrap_err() {
3636
Error::Syntax(..) => (),
37-
e => panic!("incorrect error: {:?}", e),
37+
e => panic!("incorrect error: {e:?}"),
3838
}
3939
}
4040

@@ -43,7 +43,7 @@ fn text() {
4343
let bytes = [0x7f; 128 * 1024];
4444
match from_reader::<Value, _>(&bytes[..]).unwrap_err() {
4545
Error::Syntax(..) => (),
46-
e => panic!("incorrect error: {:?}", e),
46+
e => panic!("incorrect error: {e:?}"),
4747
}
4848
}
4949

@@ -53,18 +53,18 @@ fn array_limit() {
5353
for limit in 16..256 {
5454
match from_reader_with_recursion_limit::<Value, _>(&bytes[..], limit).unwrap_err() {
5555
Error::RecursionLimitExceeded => (),
56-
e => panic!("incorrect error with limit {}: {:?}", limit, e),
56+
e => panic!("incorrect error with limit {limit}: {e:?}"),
5757
}
5858
// Data that is nested beyond the limit should fail with `RecursionLimitExceeded`
5959
match from_reader_with_recursion_limit::<Value, _>(&bytes[..limit + 1], limit).unwrap_err()
6060
{
6161
Error::RecursionLimitExceeded => (),
62-
e => panic!("incorrect error with limit {}: {:?}", limit, e),
62+
e => panic!("incorrect error with limit {limit}: {e:?}"),
6363
}
6464
// Data that is nested within the limit fails with a different error.
6565
match from_reader_with_recursion_limit::<Value, _>(&bytes[..limit], limit).unwrap_err() {
6666
Error::Io(..) => (),
67-
e => panic!("incorrect error with limit {}: {:?}", limit, e),
67+
e => panic!("incorrect error with limit {limit}: {e:?}"),
6868
}
6969
}
7070
}
@@ -75,18 +75,18 @@ fn map_limit() {
7575
for limit in 16..256 {
7676
match from_reader_with_recursion_limit::<Value, _>(&bytes[..], limit).unwrap_err() {
7777
Error::RecursionLimitExceeded => (),
78-
e => panic!("incorrect error with limit {}: {:?}", limit, e),
78+
e => panic!("incorrect error with limit {limit}: {e:?}"),
7979
}
8080
// Data that is nested beyond the limit should fail with `RecursionLimitExceeded`
8181
match from_reader_with_recursion_limit::<Value, _>(&bytes[..limit + 1], limit).unwrap_err()
8282
{
8383
Error::RecursionLimitExceeded => (),
84-
e => panic!("incorrect error with limit {}: {:?}", limit, e),
84+
e => panic!("incorrect error with limit {limit}: {e:?}"),
8585
}
8686
// Data that is nested within the limit fails with a different error.
8787
match from_reader_with_recursion_limit::<Value, _>(&bytes[..limit], limit).unwrap_err() {
8888
Error::Io(..) => (),
89-
e => panic!("incorrect error with limit {}: {:?}", limit, e),
89+
e => panic!("incorrect error with limit {limit}: {e:?}"),
9090
}
9191
}
9292
}

0 commit comments

Comments
 (0)