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

remove allocation in deserialization #28

Merged
merged 1 commit into from
Jul 18, 2024
Merged
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
19 changes: 9 additions & 10 deletions src/wire/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@
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 48 in src/wire/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/wire/mod.rs#L45-L48

Added lines #L45 - L48 were not covered by tests
}
}
}

Expand Down