Skip to content

Add Unit::Calc #15

@MrGVSV

Description

@MrGVSV

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions