Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
remove allocation in deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Jul 15, 2024
1 parent 10acbcf commit 0638c30
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/wire/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ mod serde_rfc3339 {
where
D: Deserializer<'de>,
{
Ok(String::deserialize(deserializer)
.and_then(|rfc_str| {
DateTime::parse_from_rfc3339(&rfc_str).map_err(|_| {
serde::de::Error::invalid_value(
Unexpected::Str(&rfc_str),
&"Invalid RFC3339 string",
)
})
})?
.into())
let rfc_str = <&str as Deserialize>::deserialize(deserializer)?;

match DateTime::parse_from_rfc3339(rfc_str) {
Ok(datetime) => Ok(datetime.into()),
Err(_) => Err(serde::de::Error::invalid_value(
Unexpected::Str(rfc_str),
&"Invalid RFC3339 string",
)),

Check warning on line 46 in src/wire/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/wire/mod.rs#L43-L46

Added lines #L43 - L46 were not covered by tests
}
}
}

Expand Down

0 comments on commit 0638c30

Please sign in to comment.