Skip to main content

datex_core/values/value/ops/
add_assign.rs

1use core::ops::AddAssign;
2
3use crate::values::value::Value;
4
5// TODO #119: crate a TryAddAssign trait etc.
6impl<T> AddAssign<T> for Value
7where
8    Value: From<T>,
9{
10    fn add_assign(&mut self, rhs: T) {
11        let rhs: Value = rhs.into();
12        match (self, rhs) {
13            (Value::Core(lhs), Value::Core(rhs)) => {
14                *lhs += rhs;
15            }
16            (Value::Core(lhs), Value::Native(rhs)) => {
17                *lhs += rhs;
18            }
19            (_, Value::Core(_)) => {
20                todo!("Handle add assign for non-Core and Core values")
21            }
22            (_, _) => {
23                todo!("Handle add assign for non-Core values")
24            }
25        }
26    }
27}