boxing_day/
lib.rs

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