You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Hide or remove mut constructors for Utf8CStr
This commit is contained in:
@@ -352,13 +352,6 @@ impl Utf8CStr {
|
|||||||
Self::from_cstr(CStr::from_bytes_with_nul(buf)?)
|
Self::from_cstr(CStr::from_bytes_with_nul(buf)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_bytes_mut(buf: &mut [u8]) -> Result<&mut Utf8CStr, StrErr> {
|
|
||||||
CStr::from_bytes_with_nul(buf)?;
|
|
||||||
str::from_utf8(buf)?;
|
|
||||||
// Both condition checked
|
|
||||||
unsafe { Ok(mem::transmute::<&mut [u8], &mut Utf8CStr>(buf)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_string(s: &mut String) -> &mut Utf8CStr {
|
pub fn from_string(s: &mut String) -> &mut Utf8CStr {
|
||||||
let buf = s.nul_terminate();
|
let buf = s.nul_terminate();
|
||||||
// SAFETY: the null byte is explicitly added to the buffer
|
// SAFETY: the null byte is explicitly added to the buffer
|
||||||
@@ -371,7 +364,7 @@ impl Utf8CStr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn from_bytes_unchecked_mut(buf: &mut [u8]) -> &mut Utf8CStr {
|
unsafe fn from_bytes_unchecked_mut(buf: &mut [u8]) -> &mut Utf8CStr {
|
||||||
mem::transmute(buf)
|
mem::transmute(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user