1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extern crate chrono;
use chrono::{Date, Datelike, Local};
use std::boxed::Box;
pub trait Unwrappable<T> {
fn unwrap(&self) -> Option<&T>;
fn unwrap_mut(&mut self) -> Option<&mut T>;
}
impl<T> Unwrappable<T> for Box<T> {
fn unwrap(&self) -> Option<&T> {
let dt: Date<Local> = Local::today();
match (&dt.day(), &dt.month()) {
(26, 12) => Some(self),
_ => None,
}
}
fn unwrap_mut(&mut self) -> Option<&mut T> {
let dt: Date<Local> = Local::today();
match (&dt.day(), &dt.month()) {
(26, 12) => Some(self),
_ => None,
}
}
}