Skip to content

Commit 46116e5

Browse files
burtonageoThomas Bahn
authored and
Thomas Bahn
committed
Remove unsafe blocks for Deref impls of AsciiString
1 parent 41fb082 commit 46116e5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/ascii_string.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,14 @@ impl Deref for AsciiString {
360360

361361
#[inline]
362362
fn deref(&self) -> &AsciiStr {
363-
let ptr = &*self.vec as *const [AsciiChar] as *const AsciiStr;
364-
unsafe { &*ptr }
363+
self.vec.as_slice().as_ref()
365364
}
366365
}
367366

368367
impl DerefMut for AsciiString {
369368
#[inline]
370369
fn deref_mut(&mut self) -> &mut AsciiStr {
371-
let ptr = &mut *self.vec as *mut [AsciiChar] as *mut AsciiStr;
372-
unsafe { &mut *ptr }
370+
self.vec.as_mut_slice().as_mut()
373371
}
374372
}
375373

0 commit comments

Comments
 (0)