Skip to content

Make derived Display non-allocating and padding-aware - #503

Open
Ddystopia wants to merge 1 commit into
Peternator7:masterfrom
Ddystopia:display-no-alloc
Open

Ddystopia wants to merge 1 commit into
Peternator7:masterfrom
Ddystopia:display-no-alloc

Conversation

@Ddystopia

Copy link
Copy Markdown

Tuple variants with interpolated fields formatted through format!,
allocating a String on every call and failing to compile in no_std
crates. Struct variants used format_args! but ignored width, fill,
alignment and precision, unlike unit variants.

Interpolated variants now write through a generated helper that applies
the formatter options like Formatter::pad does for &str, without
buffering. Without width or precision it is a plain write_fmt. With a
width, the arguments are formatted once into a counting sink to measure
the padding, then written.

Tuple variants with interpolated fields formatted through `format!`,
allocating a String on every call and failing to compile in `no_std`
crates. Struct variants used `format_args!` but ignored width, fill,
alignment and precision, unlike unit variants.

Interpolated variants now write through a generated helper that applies
the formatter options like `Formatter::pad` does for `&str`, without
buffering. Without width or precision it is a plain `write_fmt`. With a
width, the arguments are formatted once into a counting sink to measure
the padding, then written.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant