1
Fork 0

Get rid of core::fmt::FormatSpec.

This commit is contained in:
Mara Bos 2023-04-20 18:07:34 +02:00
parent 938efe6f49
commit bca80d811c
2 changed files with 6 additions and 11 deletions

View file

@ -1277,14 +1277,14 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
} }
unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[ArgumentV1<'_>]) -> Result { unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[ArgumentV1<'_>]) -> Result {
fmt.fill = arg.format.fill; fmt.fill = arg.fill;
fmt.align = arg.format.align; fmt.align = arg.align;
fmt.flags = arg.format.flags; fmt.flags = arg.flags;
// SAFETY: arg and args come from the same Arguments, // SAFETY: arg and args come from the same Arguments,
// which guarantees the indexes are always within bounds. // which guarantees the indexes are always within bounds.
unsafe { unsafe {
fmt.width = getcount(args, &arg.format.width); fmt.width = getcount(args, &arg.width);
fmt.precision = getcount(args, &arg.format.precision); fmt.precision = getcount(args, &arg.precision);
} }
// Extract the correct argument // Extract the correct argument

View file

@ -7,11 +7,6 @@
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Placeholder { pub struct Placeholder {
pub position: usize, pub position: usize,
pub format: FormatSpec,
}
#[derive(Copy, Clone)]
pub struct FormatSpec {
pub fill: char, pub fill: char,
pub align: Alignment, pub align: Alignment,
pub flags: u32, pub flags: u32,
@ -29,7 +24,7 @@ impl Placeholder {
precision: Count, precision: Count,
width: Count, width: Count,
) -> Self { ) -> Self {
Self { position, format: FormatSpec { fill, align, flags, precision, width } } Self { position, fill, align, flags, precision, width }
} }
} }