optional_struct_internal/
lib.rs

1pub trait Applyable<T> {
2    fn apply_to(self, t: &mut T);
3}
4
5impl<T> Applyable<T> for Option<T> {
6    fn apply_to(self, t: &mut T) {
7        if let Some(s) = self {
8            *t = s;
9        }
10    }
11}
12
13impl<T> Applyable<T> for T {
14    fn apply_to(self, t: &mut T) {
15        *t = self;
16    }
17}