I've submitted the following pull request to add `Length` and
`ScaleFactor` types to rust-geom. These types allow us to specify the
unit of measure for any geometric quantity, and check at compile time
that the correct conversion is applied before sending a value expressed
in one unit to a function expecting a different unit:
https://github.com/mozilla-servo/rust-geom/pull/35
I also submitted this pull request which demonstrates the use of these
types by converting some of the compositor code to use them:
https://github.com/mozilla/servo/pull/2444
Notably, this found a bug in `on_mouse_window_move_event_class` where a
unit conversion was missing. After tagging the associated functions and
values with units, this code would no longer compile until the bug was
fixed:
https://github.com/mbrubeck/servo/commit/c87cdcebb409f6b9bf5853514cd1a519ea49c2bc#diff-7b2596670fc5f8be65a6be4df2f0229eL639
Since I hope these types will used pervasively in Servo, I want to make
sure everyone has a chance to comment on their design and implementation
before they land. Please feel free to comment in the PRs above or in
this thread!
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo