diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-06-05 23:29:03 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-03 18:57:16 +0200 |
| commit | 82c6037b2adac3032191e76098774a334550ead2 (patch) | |
| tree | e6feebd0fd357688aa1af48281ffd71075319ef1 /library/alloc/src | |
| parent | 6268d0aa34b46981533b09827c1454b8cf27e032 (diff) | |
| download | rust-82c6037b2adac3032191e76098774a334550ead2.tar.gz rust-82c6037b2adac3032191e76098774a334550ead2.zip | |
Implement `int_format_into` feature
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() } } } )* |
