Skip to content

Commit 8e4117b

Browse files
committed
feat: implement Display for Expires
1 parent 0fbde12 commit 8e4117b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/common/expires.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::time::SystemTime;
1+
use std::{fmt, time::SystemTime};
22

33
use crate::util::HttpDate;
44

@@ -48,3 +48,25 @@ impl From<Expires> for SystemTime {
4848
date.0.into()
4949
}
5050
}
51+
52+
impl fmt::Display for Expires {
53+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54+
self.0.fmt(f)
55+
}
56+
}
57+
58+
#[cfg(test)]
59+
mod tests {
60+
use super::super::test_decode;
61+
use super::*;
62+
63+
fn expires(s: &str) -> Expires {
64+
test_decode(&[s]).unwrap()
65+
}
66+
67+
#[test]
68+
fn format() {
69+
let s = "Thu, 01 Dec 1994 16:00:00 GMT";
70+
assert_eq!(expires(s).to_string(), s);
71+
}
72+
}

0 commit comments

Comments
 (0)