mirror of
https://github.com/eternal-flame-AD/unitdc-rs.git
synced 2025-01-22 06:38:41 -06:00
improve display of multiple base units
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
8bffee834c
commit
34f62ae693
1 changed files with 5 additions and 1 deletions
|
@ -180,7 +180,11 @@ impl Display for UnitCombo {
|
||||||
exponents.sort_by(|a, b| b.exponent.cmp(&a.exponent));
|
exponents.sort_by(|a, b| b.exponent.cmp(&a.exponent));
|
||||||
for exponent in exponents.iter() {
|
for exponent in exponents.iter() {
|
||||||
if exponent.exponent == 1 {
|
if exponent.exponent == 1 {
|
||||||
|
if exponents.len() > 1 {
|
||||||
|
write!(f, "({})", exponent.unit.symbol)?;
|
||||||
|
} else {
|
||||||
write!(f, "{}", exponent.unit.symbol)?;
|
write!(f, "{}", exponent.unit.symbol)?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
write!(f, "({}^{})", exponent.unit.symbol, exponent.exponent)?;
|
write!(f, "({}^{})", exponent.unit.symbol, exponent.exponent)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue