Skip to content

Commit

Permalink
Merge #532
Browse files Browse the repository at this point in the history
532: Fix clippy lint about format args r=jonasbb a=jonasbb

bors r+

Co-authored-by: Jonas Bushart <[email protected]>
  • Loading branch information
bors[bot] and jonasbb authored Dec 5, 2022
2 parents c7361ef + f1fc517 commit d06b021
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 28 deletions.
3 changes: 1 addition & 2 deletions serde_with/src/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ where
let length = bytes.len();
bytes.try_into().map_err(|_e: T::Error| {
DeError::custom(format_args!(
"Can't convert a Byte Vector of length {} to the output type.",
length
"Can't convert a Byte Vector of length {length} to the output type."
))
})
}
Expand Down
21 changes: 7 additions & 14 deletions serde_with/src/chrono_0_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ pub mod datetime_utc_ts_seconds_from_any {
Ok(DateTime::<Utc>::from_utc(ndt, Utc))
} else {
Err(DeError::custom(format_args!(
"a timestamp which can be represented in a DateTime but received '{}'",
value
"a timestamp which can be represented in a DateTime but received '{value}'"
)))
}
}
Expand All @@ -94,8 +93,7 @@ pub mod datetime_utc_ts_seconds_from_any {
Ok(DateTime::<Utc>::from_utc(ndt, Utc))
} else {
Err(DeError::custom(format_args!(
"a timestamp which can be represented in a DateTime but received '{}'",
value
"a timestamp which can be represented in a DateTime but received '{value}'"
)))
}
}
Expand All @@ -111,8 +109,7 @@ pub mod datetime_utc_ts_seconds_from_any {
Ok(DateTime::<Utc>::from_utc(ndt, Utc))
} else {
Err(DeError::custom(format_args!(
"a timestamp which can be represented in a DateTime but received '{}'",
value
"a timestamp which can be represented in a DateTime but received '{value}'"
)))
}
}
Expand All @@ -131,8 +128,7 @@ pub mod datetime_utc_ts_seconds_from_any {
Ok(DateTime::<Utc>::from_utc(ndt, Utc))
} else {
Err(DeError::custom(format_args!(
"a timestamp which can be represented in a DateTime but received '{}'",
value
"a timestamp which can be represented in a DateTime but received '{value}'"
)))
}
} else {
Expand All @@ -144,8 +140,7 @@ pub mod datetime_utc_ts_seconds_from_any {
let subseclen = subseconds.chars().count() as u32;
if subseclen > 9 {
return Err(DeError::custom(format_args!(
"DateTimes only support nanosecond precision but '{}' has more than 9 digits.",
value
"DateTimes only support nanosecond precision but '{value}' has more than 9 digits."
)));
}

Expand All @@ -157,8 +152,7 @@ pub mod datetime_utc_ts_seconds_from_any {
Ok(DateTime::<Utc>::from_utc(ndt, Utc))
} else {
Err(DeError::custom(format_args!(
"a timestamp which can be represented in a DateTime but received '{}'",
value
"a timestamp which can be represented in a DateTime but received '{value}'"
)))
}
} else {
Expand Down Expand Up @@ -220,8 +214,7 @@ where
Ok(dur) => dur,
Err(msg) => {
return Err(DeError::custom(format_args!(
"Duration is outside of the representable range: {}",
msg
"Duration is outside of the representable range: {msg}"
)))
}
};
Expand Down
6 changes: 3 additions & 3 deletions serde_with/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ where
type Value = [T; M];

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_fmt(format_args!("an array of size {}", M))
formatter.write_fmt(format_args!("an array of size {M}"))
}

fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>
Expand Down Expand Up @@ -1327,7 +1327,7 @@ impl<'de, const N: usize> DeserializeAs<'de, [u8; N]> for Bytes {
type Value = [u8; M];

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_fmt(format_args!("an byte array of size {}", M))
formatter.write_fmt(format_args!("an byte array of size {M}"))
}

fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>
Expand Down Expand Up @@ -1370,7 +1370,7 @@ impl<'de, const N: usize> DeserializeAs<'de, &'de [u8; N]> for Bytes {
type Value = &'de [u8; M];

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_fmt(format_args!("a borrowed byte array of size {}", M))
formatter.write_fmt(format_args!("a borrowed byte array of size {M}"))
}

fn visit_borrowed_bytes<E>(self, v: &'de [u8]) -> Result<Self::Value, E>
Expand Down
3 changes: 1 addition & 2 deletions serde_with/src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ where
let length = vec.len();
vec.try_into().map_err(|_e: T::Error| {
DeError::custom(format_args!(
"Can't convert a Byte Vector of length {} to the output type.",
length
"Can't convert a Byte Vector of length {length} to the output type."
))
})
})
Expand Down
3 changes: 1 addition & 2 deletions serde_with/src/time_0_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ where
Ok(dur) => dur,
Err(msg) => {
return Err(DeError::custom(format_args!(
"Duration is outside of the representable range: {}",
msg
"Duration is outside of the representable range: {msg}"
)))
}
};
Expand Down
3 changes: 1 addition & 2 deletions serde_with/src/utils/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ fn parse_float_into_time_parts(mut value: &str) -> Result<(Sign, u64, u32), Pars
if subseclen > 9 {
#[cfg(feature = "alloc")]
return Err(ParseFloatError::Custom(alloc::format!(
"Duration and Timestamps with no more than 9 digits precision, but '{}' has more",
value
"Duration and Timestamps with no more than 9 digits precision, but '{value}' has more"
)));
#[cfg(not(feature = "alloc"))]
return Err(ParseFloatError::Custom(
Expand Down
2 changes: 1 addition & 1 deletion serde_with/tests/serde_as/enum_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn bytes_debug_readable(bytes: &[u8]) -> String {
for &byte in bytes {
match byte {
non_printable if !(0x20..0x7f).contains(&non_printable) => {
write!(result, "\\x{:02x}", byte).unwrap();
write!(result, "\\x{byte:02x}").unwrap();
}
b'\\' => result.push_str("\\\\"),
_ => {
Expand Down
3 changes: 1 addition & 2 deletions serde_with/tests/version_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ fn test_docs_rs_url_point_to_current_version() -> Result<(), Box<dyn std::error:
let pkg_version = env!("CARGO_PKG_VERSION");

let re = regex::Regex::new(&format!(
"https?://docs.rs/{}/((\\d[^/]+|\\*|latest))/",
pkg_name
"https?://docs.rs/{pkg_name}/((\\d[^/]+|\\*|latest))/"
))?;
let mut error = false;

Expand Down

0 comments on commit d06b021

Please sign in to comment.