From c35d38c95f601d74ef4267d7e2bc12c79074d690 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 15 Apr 2020 23:00:14 +0200 Subject: [PATCH] Fix minor style inconsistencies in serde::duration --- src/serde/duration/opt_ms.rs | 11 +++++------ src/serde/duration/secs.rs | 7 +++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/serde/duration/opt_ms.rs b/src/serde/duration/opt_ms.rs index 0704324d..47d14b9a 100644 --- a/src/serde/duration/opt_ms.rs +++ b/src/serde/duration/opt_ms.rs @@ -10,6 +10,7 @@ use serde::{ }; /// Serialize an Option. +/// /// Will fail if integer is greater than the maximum integer that can be /// unambiguously represented by an f64. pub fn serialize(opt_duration: &Option, serializer: S) -> Result @@ -26,6 +27,7 @@ where } /// Deserializes an Option. +/// /// Will fail if integer is greater than the maximum integer that can be /// unambiguously represented by an f64. pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> @@ -38,17 +40,14 @@ where #[cfg(test)] mod tests { + use std::time::Duration; + use serde::{Deserialize, Serialize}; use serde_json::json; - use std::time::Duration; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] struct DurationTest { - #[serde( - with = "crate::serde::duration::opt_ms", - default, - skip_serializing_if = "Option::is_none" - )] + #[serde(with = "super", default, skip_serializing_if = "Option::is_none")] timeout: Option, } diff --git a/src/serde/duration/secs.rs b/src/serde/duration/secs.rs index 1e60052a..f8940092 100644 --- a/src/serde/duration/secs.rs +++ b/src/serde/duration/secs.rs @@ -10,6 +10,7 @@ use serde::{ }; /// Serializes a Duration to an integer representing seconds. +/// /// Will fail if integer is greater than the maximum integer that can be /// unambiguously represented by an f64. pub fn serialize(duration: &Duration, serializer: S) -> Result @@ -23,6 +24,7 @@ where } /// Deserializes an integer representing seconds into a Duration. +/// /// Will fail if integer is greater than the maximum integer that can be /// unambiguously represented by an f64. pub fn deserialize<'de, D>(deserializer: D) -> Result @@ -34,13 +36,14 @@ where #[cfg(test)] mod tests { + use std::time::Duration; + use serde::{Deserialize, Serialize}; use serde_json::json; - use std::time::Duration; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] struct DurationTest { - #[serde(with = "crate::serde::duration::secs")] + #[serde(with = "super")] timeout: Duration, }