aboutsummaryrefslogtreecommitdiff
path: root/niri-config/src/utils/merge_with.rs
blob: 857e2146fa3b3ef059fa9553597c94805b4bf2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub trait MergeWith<T> {
    fn merge_with(&mut self, part: &T);

    fn merged_with(mut self, part: &T) -> Self
    where
        Self: Sized,
    {
        self.merge_with(part);
        self
    }

    fn from_part(part: &T) -> Self
    where
        Self: Default + Sized,
    {
        Self::default().merged_with(part)
    }
}