From 8e4117b96536d87a5da3f3953a75b966f8e936a5 Mon Sep 17 00:00:00 2001 From: tottoto Date: Mon, 5 Aug 2024 00:47:03 +0900 Subject: [PATCH] feat: implement Display for Expires --- src/common/expires.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/common/expires.rs b/src/common/expires.rs index 1378e121..e9f1863b 100644 --- a/src/common/expires.rs +++ b/src/common/expires.rs @@ -1,4 +1,4 @@ -use std::time::SystemTime; +use std::{fmt, time::SystemTime}; use crate::util::HttpDate; @@ -48,3 +48,25 @@ impl From for SystemTime { date.0.into() } } + +impl fmt::Display for Expires { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + +#[cfg(test)] +mod tests { + use super::super::test_decode; + use super::*; + + fn expires(s: &str) -> Expires { + test_decode(&[s]).unwrap() + } + + #[test] + fn format() { + let s = "Thu, 01 Dec 1994 16:00:00 GMT"; + assert_eq!(expires(s).to_string(), s); + } +}