diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-19 21:16:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-19 21:16:01 +0100 |
| commit | 84e9f2900758902fbbe6d09ec0f35546c220dedf (patch) | |
| tree | d243042f4fb3b864cacbe50f6d6dddc9b798c0a9 /library/core/src/fmt | |
| parent | ed49386d3aa3a445a9889707fd405df01723eced (diff) | |
| parent | eec49bbf59c922060a5785a47d885529e6cb2ac8 (diff) | |
Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-se
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
Diffstat (limited to 'library/core/src/fmt')
| -rw-r--r-- | library/core/src/fmt/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index a1bf3a4d7a7..764e7fff33e 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -3,7 +3,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell}; -use crate::char::EscapeDebugExtArgs; +use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8}; use crate::marker::PhantomData; use crate::num::fmt as numfmt; use crate::ops::Deref; @@ -187,7 +187,7 @@ pub trait Write { /// ``` #[stable(feature = "fmt_write_char", since = "1.1.0")] fn write_char(&mut self, c: char) -> Result { - self.write_str(c.encode_utf8(&mut [0; 4])) + self.write_str(c.encode_utf8(&mut [0; MAX_LEN_UTF8])) } /// Glue for usage of the [`write!`] macro with implementors of this trait. @@ -2768,7 +2768,7 @@ impl Display for char { if f.options.width.is_none() && f.options.precision.is_none() { f.write_char(*self) } else { - f.pad(self.encode_utf8(&mut [0; 4])) + f.pad(self.encode_utf8(&mut [0; MAX_LEN_UTF8])) } } } |
