Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'as_imperial()' function / type for nice formatting. #2

Open
thejpster opened this issue Aug 28, 2017 · 1 comment
Open

Add 'as_imperial()' function / type for nice formatting. #2

thejpster opened this issue Aug 28, 2017 · 1 comment

Comments

@thejpster
Copy link
Member

I would like to see the following work:

let d = Distance::from_metres(100);
println!("{}", d.as_imperial()); // gives 109 yards, 1'1"

Will require fn as_imperial(&'a self) -> DistanceImperial<'a>, where DistanceImperial just holds a reference to the parent, and impl's Display. You could also have a metric version as_metric() which only gives one unit, but selects the appropriate SI scale (e.g. 33.3km, 33.3m, 33.3cm, 33.3mm, 33.3μm, etc).

@thejpster thejpster mentioned this issue Aug 28, 2017
@thejpster
Copy link
Member Author

Selecting of SI scales now happens through get_appropriate_units. I'm still interested in as_imperial though, which would select an appropriate imperial unit (or collection of imperial units, e.g. 14 miles, 1200 yards, 3', 2¼")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant