Skip to content

Commit

Permalink
chore: convert from #1875
Browse files Browse the repository at this point in the history
  • Loading branch information
indietyp committed Apr 10, 2023
1 parent 61a5937 commit 3ec049a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/deer/src/impls/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ mod floating;
mod integral;
mod non_zero;
mod string;
mod time;
mod unit;
13 changes: 13 additions & 0 deletions libs/deer/src/impls/core/time.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use core::time::Duration;

use error_stack::Result;

use crate::{error::DeserializeError, Deserialize, Deserializer};

impl<'de> Deserialize<'de> for Duration {
type Reflection = <f64 as Deserialize<'de>>::Reflection;

fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, DeserializeError> {
f64::deserialize(de).map(Self::from_secs_f64)
}
}

0 comments on commit 3ec049a

Please sign in to comment.