Skip to content

Commit 29b3410

Browse files
committed
Simplify pointer usage in Buffer::format method
1 parent bbf077f commit 29b3410

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ mod u128_ext;
5555

5656
use core::hint;
5757
use core::mem::{self, MaybeUninit};
58-
use core::ptr;
5958
use core::str;
6059
#[cfg(feature = "no-panic")]
6160
use no_panic::no_panic;
@@ -105,9 +104,8 @@ impl Buffer {
105104
/// representation within the buffer.
106105
#[cfg_attr(feature = "no-panic", no_panic)]
107106
pub fn format<I: Integer>(&mut self, i: I) -> &str {
108-
let string = i.write(unsafe {
109-
&mut *ptr::addr_of_mut!(self.bytes).cast::<<I as private::Sealed>::Buffer>()
110-
});
107+
let buf_ptr = self.bytes.as_mut_ptr().cast();
108+
let string = i.write(unsafe { &mut *buf_ptr });
111109
if string.len() > I::MAX_STR_LEN {
112110
unsafe { hint::unreachable_unchecked() };
113111
}

0 commit comments

Comments
 (0)