mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uucore/format: cast signedint to unsignedint if possible
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user