Fix errors in documentation tests
This commit is contained in:
parent
fcda4cc2ca
commit
2db91e8538
|
@ -33,7 +33,7 @@ pub struct SecondsStringTimestampVisitor;
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// let my_s: S = serde_json::from_str(&as_string)?;
|
/// let my_s: S = serde_json::from_str(&as_string)?;
|
||||||
/// assert_eq!(my_s.time, time);
|
/// assert_eq!(my_s.time, time);
|
||||||
/// # Ok::<(), serde_json::Error>(())
|
/// // Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
pub mod ts_seconds_str {
|
pub mod ts_seconds_str {
|
||||||
|
@ -65,7 +65,7 @@ pub mod ts_seconds_str {
|
||||||
/// };
|
/// };
|
||||||
/// let as_string = serde_json::to_string(&my_s)?;
|
/// let as_string = serde_json::to_string(&my_s)?;
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// # Ok::<(), serde_json::Error>(())
|
/// // Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -92,7 +92,7 @@ pub mod ts_seconds_str {
|
||||||
///
|
///
|
||||||
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
||||||
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).unwrap() });
|
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).unwrap() });
|
||||||
/// # Ok::<(), serde_json::Error>(())
|
/// // Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
|
pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
|
||||||
where
|
where
|
||||||
|
@ -143,7 +143,7 @@ pub mod ts_seconds_str {
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// let my_s: S = serde_json::from_str(&as_string)?;
|
/// let my_s: S = serde_json::from_str(&as_string)?;
|
||||||
/// assert_eq!(my_s.time, time);
|
/// assert_eq!(my_s.time, time);
|
||||||
/// # Ok::<(), serde_json::Error>(())
|
/// // Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub mod ts_seconds_option_str {
|
pub mod ts_seconds_option_str {
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
@ -172,7 +172,7 @@ pub mod ts_seconds_option_str {
|
||||||
/// };
|
/// };
|
||||||
/// let as_string = serde_json::to_string(&my_s)?;
|
/// let as_string = serde_json::to_string(&my_s)?;
|
||||||
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
/// assert_eq!(as_string, r#"{"time":"1431684000"}"#);
|
||||||
/// # Ok::<(), serde_json::Error>(())
|
/// // Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -202,7 +202,7 @@ pub mod ts_seconds_option_str {
|
||||||
///
|
///
|
||||||
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
/// let my_s: S = serde_json::from_str(r#"{ "time": "1431684000" }"#)?;
|
||||||
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).single() });
|
/// assert_eq!(my_s, S { time: Utc.timestamp_opt(1431684000, 0).single() });
|
||||||
/// # Ok::<(), serde_json::Error>(())
|
/// // Ok::<(), serde_json::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
|
pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in New Issue