-
Notifications
You must be signed in to change notification settings - Fork 126
Metric Teaspoons, Tablespoons & Cups #525
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
Open
azyritedev
wants to merge
5
commits into
iliekturtles:master
Choose a base branch
from
azyritedev:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bbc60a
feat: add US, metric & aus tsp, tbsp, cups
azyritedev 0389cfd
fix: silence some deprecation warnings from our own code
azyritedev b6a79b7
fix: base unit is L³ not L, missing cups
azyritedev 266a446
fix: add us cups, deprecation msgs w/o _aus
azyritedev 6c716a8
feat: us_legal vs us_customary cups
azyritedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| //! Volume (base unit cubic meter, m³). | ||
| #![allow(deprecated)] // rust warns of our own deprecations | ||
|
|
||
| quantity! { | ||
| /// Volume (base unit cubic meter, m³). | ||
|
|
@@ -63,7 +64,11 @@ quantity! { | |
| @cubic_inch: 1.638_706_E-5; "in³", "cubic inch", "cubic inches"; | ||
| @cubic_mile: 4.168_182_E9; "mi³", "cubic mile", "cubic miles"; | ||
| @cubic_yard: 7.645_549_E-1; "yd³", "cubic yard", "cubic yards"; | ||
| @cup: 2.365_882_E-4; "cup", "cup", "cups"; | ||
| #[doc = "US cups. Deprecated."] | ||
| #[deprecated(note = "please use suffixed unit e.g. _us, _metric")] | ||
| @cup: 2.365_882_E-4; "cup (US)", "cup (US)", "cups (US)"; | ||
| @cup_us: 2.365_882_E-4; "cup (US)", "cup (US)", "cups (US)"; | ||
| @cup_metric: prefix!(milli) * prefix!(milli) * 250.0; "cup", "cup", "cups"; | ||
| @fluid_ounce: 2.957_353_E-5; "fl oz", "fluid ounce", "fluid ounces"; | ||
| @fluid_ounce_imperial: 2.841_306_E-5; "fl oz (UK)", "Imperial fluid ounce", "Imperial fluid ounces"; | ||
| @gallon_imperial: 4.546_09_E-3; "gal (UK)", "Imperial gallon", "Imperial gallons"; | ||
|
|
@@ -97,8 +102,19 @@ quantity! { | |
| @quart_dry: 1.101_221_E-3; "dry qt", "dry quart", "dry quarts"; | ||
| @quart_liquid: 9.463_529_E-4; "liq qt", "liquid quart", "liquid quarts"; | ||
| @stere: 1.0_E0; "st", "stere", "steres"; | ||
| @tablespoon: 1.478_676_E-5; "tbsp", "tablespoon", "tablespoons"; | ||
| @teaspoon: 4.928_922_E-6; "tsp", "teaspoon", "teaspoons"; | ||
| #[deprecated(note = "please use suffixed unit e.g. _us, _aus, _metric")] | ||
| #[doc = "US tablespoons. Deprecated."] // doc is required here, see macro arms in unit.rs L368 vs L374 | ||
| @tablespoon: 1.478_676_E-5; "tbsp (US)", "tablespoon (US)", "tablespoons (US)"; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure what to do with the naming changes — technically this could be considered breaking if a library user is relying on matching the abbreviations or names. However since this is the SI module I assume that the metric units should take priority. |
||
| #[deprecated(note = "please use suffixed unit e.g. _us, _metric")] | ||
| #[doc = "US teaspoons. Deprecated."] | ||
| @teaspoon: 4.928_922_E-6; "tsp (US)", "teaspoon (US)", "teaspoons (US)"; | ||
| @tablespoon_us: 1.478_676_E-5; "tbsp (US)", "US tablespoon", "US tablespoons"; | ||
| @teaspoon_us: 4.928_922_E-6; "tsp (US)", "US teaspoon", "US teaspoons"; | ||
| @tablespoon_metric: prefix!(milli) * prefix!(milli) * 15.0; "tbsp", "tablespoon", "tablespoons"; | ||
| @teaspoon_metric: prefix!(milli) * prefix!(milli) * 5.0; "tsp", "teaspoon", "teaspoons"; | ||
| // note: Australian tablespoons are 20mL (so one teaspoon is 1/4 of a tbsp) instead of the | ||
| // typical 15mL. There is no difference in the Australian teaspoon. | ||
| @tablespoon_aus: prefix!(milli) * prefix!(milli) * 20.0; "tbsp (AU)", "tablespoon (AU)", "tablespoons (AU)"; | ||
| @register_ton: 2.831_685_E0; "RT", "register ton", "register tons"; | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is 'US customary' - there is also 'US legal' (240ml precisely) so it's probably worth being clear what it is even if not also providing the other.
(There's also the old UK imperial system based cup size, I believe it's the same number of floz as US customary cup, but since UK floz != US floz it works out to be about 284ml. It's obsolete though, and I think was never really that common (vs. floz & pints even if they work out to round cups or fractions) so maybe not worth adding.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thanks for the suggestion.
Modified
cup_usto becup_us_customaryand added acup_us_legalat 240mL, and also changed unit names in 6c716a8