Skip to content

Commit 471ca0d

Browse files
cacttermrobinson
andauthored
The scope of the unsafe block can be appropriately reduced (#263)
* Shrink unsafe block * Remove empty lines --------- Co-authored-by: Martin Robinson <[email protected]>
1 parent 021012e commit 471ca0d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/atom.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -383,28 +383,24 @@ impl<Static: StaticAtomSet> Atom<Static> {
383383

384384
#[inline(always)]
385385
fn inline_atom_slice(x: &NonZeroU64) -> &[u8] {
386-
unsafe {
387386
let x: *const NonZeroU64 = x;
388387
let mut data = x as *const u8;
389388
// All except the lowest byte, which is first in little-endian, last in big-endian.
390389
if cfg!(target_endian = "little") {
391-
data = data.offset(1);
390+
data = unsafe { data.offset(1) };
392391
}
393392
let len = 7;
394-
slice::from_raw_parts(data, len)
395-
}
393+
unsafe { slice::from_raw_parts(data, len) }
396394
}
397395

398396
#[inline(always)]
399-
fn inline_atom_slice_mut(x: &mut u64) -> &mut [u8] {
400-
unsafe {
397+
fn inline_atom_slice_mut(x: &mut u64) -> &mut [u8] {
401398
let x: *mut u64 = x;
402399
let mut data = x as *mut u8;
403400
// All except the lowest byte, which is first in little-endian, last in big-endian.
404401
if cfg!(target_endian = "little") {
405-
data = data.offset(1);
402+
data = unsafe { data.offset(1) };
406403
}
407404
let len = 7;
408-
slice::from_raw_parts_mut(data, len)
409-
}
405+
unsafe { slice::from_raw_parts_mut(data, len) }
410406
}

0 commit comments

Comments
 (0)