Skip to content

Commit

Permalink
make safety comments more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
TyPR124 committed Mar 16, 2020
1 parent 16712ed commit e4a65e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/sys/windows/os_str.rs
Expand Up @@ -78,15 +78,15 @@ impl Buf {

pub fn as_slice(&self) -> &Slice {
// Safety: Slice is just a wrapper for Wtf8,
// and as_slice returns &Wtf8. Therefore,
// transmuting &Wtf8 to &Slice is safe.
// and self.inner.as_slice() returns &Wtf8.
// Therefore, transmuting &Wtf8 to &Slice is safe.
unsafe { mem::transmute(self.inner.as_slice()) }
}

pub fn as_mut_slice(&mut self) -> &mut Slice {
// Safety: Slice is just a wrapper for Wtf8,
// and as_mut_slice returns &mut Wtf8. Therefore,
// transmuting &mut Wtf8 to &mut Slice is safe.
// and self.inner.as_mut_slice() returns &mut Wtf8.
// Therefore, transmuting &mut Wtf8 to &mut Slice is safe.
unsafe { mem::transmute(self.inner.as_mut_slice()) }
}

Expand Down

0 comments on commit e4a65e8

Please sign in to comment.