cargo fmt
This commit is contained in:
parent
41288b7c73
commit
32d95057a6
@ -13,7 +13,10 @@ use serde::{
|
||||
///
|
||||
/// Will fail if integer is greater than the maximum integer that can be
|
||||
/// unambiguously represented by an f64.
|
||||
pub fn serialize<S>(opt_duration: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
pub fn serialize<S>(
|
||||
opt_duration: &Option<Duration>,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
@ -30,7 +33,9 @@ where
|
||||
///
|
||||
/// 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<Option<Duration>, D::Error>
|
||||
pub fn deserialize<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<Option<Duration>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
@ -47,7 +52,11 @@ mod tests {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
struct DurationTest {
|
||||
#[serde(with = "super", default, skip_serializing_if = "Option::is_none")]
|
||||
#[serde(
|
||||
with = "super",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
timeout: Option<Duration>,
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,10 @@ use serde::{
|
||||
///
|
||||
/// Will fail if integer is greater than the maximum integer that can be
|
||||
/// unambiguously represented by an f64.
|
||||
pub fn serialize<S>(duration: &Duration, serializer: S) -> Result<S::Ok, S::Error>
|
||||
pub fn serialize<S>(
|
||||
duration: &Duration,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
@ -64,6 +67,9 @@ mod tests {
|
||||
let test = DurationTest {
|
||||
timeout: Duration::from_millis(7000),
|
||||
};
|
||||
assert_eq!(serde_json::to_value(test).unwrap(), json!({ "timeout": 7 }),);
|
||||
assert_eq!(
|
||||
serde_json::to_value(test).unwrap(),
|
||||
json!({ "timeout": 7 }),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,10 @@ use serde::{
|
||||
///
|
||||
/// Will fail if integer is greater than the maximum integer that can be unambiguously represented
|
||||
/// by an f64.
|
||||
pub fn serialize<S>(opt_time: &Option<SystemTime>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
pub fn serialize<S>(
|
||||
opt_time: &Option<SystemTime>,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
@ -28,7 +31,9 @@ where
|
||||
///
|
||||
/// 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<Option<SystemTime>, D::Error>
|
||||
pub fn deserialize<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<Option<SystemTime>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
@ -45,7 +50,11 @@ mod tests {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
struct SystemTimeTest {
|
||||
#[serde(with = "super", default, skip_serializing_if = "Option::is_none")]
|
||||
#[serde(
|
||||
with = "super",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
timestamp: Option<SystemTime>,
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user