rsiot/message/phy_quantity/ops/
add.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::super::PhyQuantity;

impl std::ops::Add for PhyQuantity {
    type Output = PhyQuantity;

    fn add(self, rhs: Self) -> Self::Output {
        if self.quantity_name != rhs.quantity_name {
            panic!(
                "Wrong operation: {:?} + {:?}",
                self.quantity_name, rhs.quantity_name
            )
        }
        Self {
            value: self.value + rhs.value,
            quantity_name: self.quantity_name,
        }
    }
}