Objective
I think it would be nice to add a new unit: Units::Calc(Box<dyn Fn(&mut CalculatedUnit)>).
This unit would take a closure that allows a user to apply multiple units similar to CSS's calc(...) and would probably end up looking something like:
let unit = Units::Calc(Box::new(|value| {
value.set(Units::Stretch(1.0));
value.sub(Units::Percent(20.0));
value.add(Units::Pixels(15.0));
}));
Considerations
This would force Units to become Clone since Box isn't Copy which might be a dealbreaker.
Objective
I think it would be nice to add a new unit:
Units::Calc(Box<dyn Fn(&mut CalculatedUnit)>).This unit would take a closure that allows a user to apply multiple units similar to CSS's
calc(...)and would probably end up looking something like:Considerations
This would force
Unitsto becomeClonesinceBoxisn'tCopywhich might be a dealbreaker.