diff options
| author | Elias Holzmann <9659253+EliasHolzmann@users.noreply.github.com> | 2023-11-22 01:52:13 +0100 |
|---|---|---|
| committer | Elias Holzmann <9659253+EliasHolzmann@users.noreply.github.com> | 2024-12-05 21:48:01 +0100 |
| commit | f17d13285c04b71c804d83fdf2eb8e82f0c6096f (patch) | |
| tree | 67682086fee5418ce80fb1db91c7e49e8ab64ccc /library/alloc/src/string.rs | |
| parent | 1d7984a132663296d0652a9059df46d2a393fcb5 (diff) | |
| download | rust-f17d13285c04b71c804d83fdf2eb8e82f0c6096f.tar.gz rust-f17d13285c04b71c804d83fdf2eb8e82f0c6096f.zip | |
Added struct `fmt::FormattingOptions`
This allows to build custom `std::Formatter`s at runtime. Also added some related enums and two related methods on `std::Formatter`.
Diffstat (limited to 'library/alloc/src/string.rs')
| -rw-r--r-- | library/alloc/src/string.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index e0576c25515..d0d0276c55e 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -43,6 +43,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::error::Error; +use core::fmt::FormattingOptions; use core::iter::FusedIterator; #[cfg(not(no_global_oom_handling))] use core::iter::from_fn; @@ -2682,7 +2683,7 @@ impl<T: fmt::Display + ?Sized> ToString for T { #[inline] default fn to_string(&self) -> String { let mut buf = String::new(); - let mut formatter = core::fmt::Formatter::new(&mut buf); + let mut formatter = core::fmt::Formatter::new(&mut buf, FormattingOptions::new()); // Bypass format_args!() to avoid write_str with zero-length strs fmt::Display::fmt(self, &mut formatter) .expect("a Display implementation returned an error unexpectedly"); |
