Open wez opened 4 years ago
The strongly typed getters returning Length<T, U>
used to exist but were removed in part because their names weren't very ergonomic (foo.width_typed()
) and more importantly becaused it seemed that nobody used them at all (maybe due to the bad ergonomics).
We could re-introduce them since this issues shows that there is some interest in using them.
My preference would be fn get_x(&self) -> Length<T, U>
, fn get_width(&self) -> Length<T, U>
, etc. applied consistently so that all scalar member and method accessors foo
/foo()
yield a raw scalar while get_foo()
methods return a Length
.
The documentation of to_array is a mistake. We probably deleted the wrong lines when getting rid of the typed accessor and the documentation of width_typed
ended up on top of the wrong function.
I'm looking for (sort of) the inverse of
Size2D::from_lengths
, but it seems like there isn't a convenient way to access the fields in this way.The doc comment for Size2D::to_array suggests that it exposes the
Length
, but it just returns elements of typeT
.I'd like to avoid having to manually construct a length where the fields are accessed as this is potentially error prone.
Something like this, but with much better names: