Closed bschwind closed 1 year ago
@PabloMansanet can we nerd-snipe you to try an alternative implementation where Degrees
and Radians
are separate types?
I think the "2 separate types" would be just slightly more canonical, yet a bit more verbose: APIs would have to accept argument: impl Into<Radians>
(which we could alias as impl Angle
) rather than argument: Angle
.
My gut feeling would be enum { Degrees, Radians }
would be more suitable when we want to carry the difference between the 2 variants in runtime. But if we only care about interoperability, compile-time conversion (the 2 separate types) is the way to go.
But both approaches are better than status quo, I'm certainly not against merging this.
@PabloMansanet can we nerd-snipe you to try an alternative implementation where
Degrees
andRadians
are separate types?I think the "2 separate types" would be just slightly more canonical, yet a bit more verbose: APIs would have to accept
argument: impl Into<Radians>
(which we could alias asimpl Angle
) rather thanargument: Angle
.My gut feeling would be
enum { Degrees, Radians }
would be more suitable when we want to carry the difference between the 2 variants in runtime. But if we only care about interoperability, compile-time conversion (the 2 separate types) is the way to go.But both approaches are better than status quo, I'm certainly not against merging this.
I like being nerd sniped :) sure thing, I'll get through this today, even if I don't manage to get much more done other than review!
This is one possible implementation for more strongly-typed angles. Spawned from this discussion
The main goals are:
I think what we have here so far is nice, but I'm open to suggestions if we want to make it more Rust-y with new types and
impl From<_>
signatures on functions which take angles.