diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-08 03:09:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-08 03:09:56 +0200 |
| commit | d41f046de52cc578c1f821ceedf45e57ed8b360f (patch) | |
| tree | c494c2e514bf21b0152bb1dd17255bc6cc3bc361 /library/alloc/src | |
| parent | a2d45f73c70d9dec57140c9412f83586eda895f8 (diff) | |
| parent | 9943c1933d2a9a343b088b6fd7ac76417da94871 (diff) | |
| download | rust-d41f046de52cc578c1f821ceedf45e57ed8b360f.tar.gz rust-d41f046de52cc578c1f821ceedf45e57ed8b360f.zip | |
Rollup merge of #142098 - GuillaumeGomez:int_format_into, r=Amanieu
Implement `int_format_into` feature I took over rust-lang/rust#138338 with `@madhav-madhusoodanan's` approval. Since https://github.com/rust-lang/rust/pull/136264, a lot of changes happened so I made use of them to reduce the number of changes. ACP approval: https://github.com/rust-lang/libs-team/issues/546#issuecomment-2707244569 ## Associated Issue - https://github.com/rust-lang/rust/issues/138215 r? `@hanna-kruppe`
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/string.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 5f69f699867..f7a6a646b63 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2875,7 +2875,8 @@ macro_rules! impl_to_string { out = String::with_capacity(SIZE); } - out.push_str(self.unsigned_abs()._fmt(&mut buf)); + // SAFETY: `buf` is always big enough to contain all the digits. + unsafe { out.push_str(self.unsigned_abs()._fmt(&mut buf)); } out } } @@ -2887,7 +2888,8 @@ macro_rules! impl_to_string { const SIZE: usize = $unsigned::MAX.ilog10() as usize + 1; let mut buf = [core::mem::MaybeUninit::<u8>::uninit(); SIZE]; - self._fmt(&mut buf).to_string() + // SAFETY: `buf` is always big enough to contain all the digits. + unsafe { self._fmt(&mut buf).to_string() } } } )* |
