mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
uucore/format: cast signedint to unsignedint if possible
This commit is contained in:
parent
da139c9524
commit
a30dce0b7c
1 changed files with 18 additions and 0 deletions
|
@ -168,6 +168,24 @@ impl Formatter for UnsignedInt {
|
|||
}
|
||||
|
||||
fn try_from_spec(s: Spec) -> Result<Self, FormatError> {
|
||||
// A signed int spec might be mapped to an unsigned int spec if no sign is specified
|
||||
let s = if let Spec::SignedInt {
|
||||
width,
|
||||
precision,
|
||||
positive_sign: PositiveSign::None,
|
||||
alignment,
|
||||
} = s
|
||||
{
|
||||
Spec::UnsignedInt {
|
||||
variant: UnsignedIntVariant::Decimal,
|
||||
width,
|
||||
precision,
|
||||
alignment,
|
||||
}
|
||||
} else {
|
||||
s
|
||||
};
|
||||
|
||||
let Spec::UnsignedInt {
|
||||
variant,
|
||||
width,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue