about summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-06-05 23:29:03 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-07-03 18:57:16 +0200
commit82c6037b2adac3032191e76098774a334550ead2 (patch)
treee6feebd0fd357688aa1af48281ffd71075319ef1 /library/alloc/src
parent6268d0aa34b46981533b09827c1454b8cf27e032 (diff)
downloadrust-82c6037b2adac3032191e76098774a334550ead2.tar.gz
rust-82c6037b2adac3032191e76098774a334550ead2.zip
Implement `int_format_into` feature
Diffstat (limited to 'library/alloc/src')
-rw-r--r--library/alloc/src/string.rs6
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() }
             }
         }
         )*