diff options
| author | Yuri Astrakhan <YuriAstrakhan@gmail.com> | 2025-01-24 01:41:00 -0500 |
|---|---|---|
| committer | Yuri Astrakhan <YuriAstrakhan@gmail.com> | 2025-01-24 01:58:33 -0500 |
| commit | c9ae0bbffb86d45e313bfe9515af513ce6ab49c9 (patch) | |
| tree | da61bf25c3df3449d944b38d2f060e6e858ccd1e /library/core/src/fmt | |
| parent | 1c9837df1dde9b234229709e89b3672bd3cf04a4 (diff) | |
Fix `FormattingOptions` instantiation with `Default`
The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`
Diffstat (limited to 'library/core/src/fmt')
| -rw-r--r-- | library/core/src/fmt/mod.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index a033b8bd305..a1bf3a4d7a7 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -288,7 +288,7 @@ pub enum DebugAsHex { /// /// `FormattingOptions` is a [`Formatter`] without an attached [`Write`] trait. /// It is mainly used to construct `Formatter` instances. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[unstable(feature = "formatting_options", issue = "118117")] pub struct FormattingOptions { flags: u32, @@ -508,6 +508,15 @@ impl FormattingOptions { } } +#[unstable(feature = "formatting_options", issue = "118117")] +impl Default for FormattingOptions { + /// Same as [`FormattingOptions::new()`]. + fn default() -> Self { + // The `#[derive(Default)]` implementation would set `fill` to `\0` instead of space. + Self::new() + } +} + /// Configuration for formatting. /// /// A `Formatter` represents various options related to formatting. Users do not |
