-
Notifications
You must be signed in to change notification settings - Fork 99
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
Implement Display, LowerExp, UpperExp, ... #13
Comments
Something like the following should be able to meet the requirements. Note that the following code takes a lot of liberties and is just to give an idea of what should be necessary. The mod fmt {
pub struct Arguments<...> {
subunit: Subunit,
label: LabelEnum,
}
pub struct QuantityArguments<...> {
quantity: Quantity<...>,
arguments: Arguments,
}
impl Display for Arguments { ... }
impl LowerExp for Arguments { ... }
...
}
...
let l = Length::<meter>::new(10);
let a1: Arguments = Arguments::new(meter, Abbreviation);
let a2: Arguments = Arguments::new(meter, Description);
let a3: QuantityArguments = Arguments::new(l, foot, Abbreviation);
let a4: QuantityArguments = Arguments::new(l, foot, Description);
// 10 m, 10 meters, 32.8084 ft, 32.8084 feet
println!("{}, {}, {}, {}", a1.with(l), a2.with(l), a3, a4); |
I have a working implementation that'll print a |
Not exactly sure what you mean by printing raw units. Can you provide a short example? |
Something like |
Ahhh. Not needed! |
That's what I figured. PR inbound soon. |
Allows `Quantity` to be formatted with the standard library formatting traits: Binary, Debug, Display, LowerExp, LowerHex, Octal, UpperExp, UpperHex. Resolves #13.
Allows `Quantity` to be formatted with the standard library formatting traits: Binary, Debug, Display, LowerExp, LowerHex, Octal, UpperExp, UpperHex. Resolves #13.
Allows `Quantity` to be formatted with the standard library formatting traits: Binary, Debug, Display, LowerExp, LowerHex, Octal, UpperExp, UpperHex. Resolves #13.
Allows `Quantity` to be formatted with the standard library formatting traits: Binary, Debug, Display, LowerExp, LowerHex, Octal, UpperExp, UpperHex. Resolves #13.
Allows `Quantity` to be formatted with the standard library formatting traits: Binary, Debug, Display, LowerExp, LowerHex, Octal, UpperExp, UpperHex. Resolves #13.
Allows `Quantity` to be formatted with the standard library formatting traits: Binary, Debug, Display, LowerExp, LowerHex, Octal, UpperExp, UpperHex. Resolves #13.
https://doc.rust-lang.org/core/fmt/trait.Binary.html
https://doc.rust-lang.org/core/fmt/trait.Display.html
https://doc.rust-lang.org/core/fmt/trait.LowerExp.html
https://doc.rust-lang.org/core/fmt/trait.LowerHex.html
https://doc.rust-lang.org/core/fmt/trait.Octal.html
https://doc.rust-lang.org/core/fmt/trait.UpperExp.html
https://doc.rust-lang.org/core/fmt/trait.UpperHex.html
Is there a way to use the fmt syntax or flags to include an implicit unit conversion, unit abbreviation, or unit label?
Quantity
$quantities
(Dimension)BaseUnits
$unit
(Measurement units)The text was updated successfully, but these errors were encountered: