提交 e4a65e83 编写于 作者: T TyPR124

make safety comments more explicit

上级 16712ede
......@@ -78,15 +78,15 @@ pub fn from_string(s: String) -> 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()) }
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册