Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace uses of write! with write_str and write_fmt #699

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions serde_with/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ where
type Value = S;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a string")
formatter.write_str("a string")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
Expand Down Expand Up @@ -1091,7 +1091,7 @@ where
type Value = I;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a string")
formatter.write_str("a string")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
Expand Down
2 changes: 1 addition & 1 deletion serde_with/src/enum_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ where
type Value = Vec<T>;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a map of enum values")
formatter.write_str("a map of enum values")
}

fn visit_map<A: MapAccess<'de>>(self, map: A) -> Result<Self::Value, A::Error> {
Expand Down
2 changes: 1 addition & 1 deletion serde_with/src/key_value_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ where
type Value = Vec<T>;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a map")
formatter.write_str("a map")
}

fn visit_map<A: MapAccess<'de>>(self, map: A) -> Result<Self::Value, A::Error> {
Expand Down
2 changes: 1 addition & 1 deletion serde_with/src/utils/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'de> DeserializeAs<'de, DurationSigned> for DurationSeconds<String, Strict>
type Value = DurationSigned;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "a string containing a number")
formatter.write_str("a string containing a number")
}

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
Expand Down
2 changes: 1 addition & 1 deletion serde_with/tests/derives/serialize_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct A {

impl fmt::Display for A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "->{} <> {}<-", self.a, self.b)
f.write_fmt(format_args!("->{} <> {}<-", self.a, self.b))
}
}

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{byte:02x}").unwrap();
result.write_fmt(format_args!("\\x{byte:02x}")).unwrap();
}
b'\\' => result.push_str("\\\\"),
_ => {
Expand Down
Loading