Work around missing <*str>::len
This commit is contained in:
parent
e12e7fcc50
commit
f189d00d40
1 changed files with 4 additions and 4 deletions
|
@ -281,16 +281,16 @@ unsafe impl SliceIndex<str> for (ops::Bound<usize>, ops::Bound<usize>) {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn get_unchecked(self, slice: *const str) -> *const str {
|
unsafe fn get_unchecked(self, slice: *const str) -> *const str {
|
||||||
|
let len = (slice as *const [u8]).len();
|
||||||
// SAFETY: the caller has to uphold the safety contract for `get_unchecked`.
|
// SAFETY: the caller has to uphold the safety contract for `get_unchecked`.
|
||||||
unsafe { crate::slice::index::into_range_unchecked(slice.len(), self).get_unchecked(slice) }
|
unsafe { crate::slice::index::into_range_unchecked(len, self).get_unchecked(slice) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut str {
|
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut str {
|
||||||
|
let len = (slice as *mut [u8]).len();
|
||||||
// SAFETY: the caller has to uphold the safety contract for `get_unchecked_mut`.
|
// SAFETY: the caller has to uphold the safety contract for `get_unchecked_mut`.
|
||||||
unsafe {
|
unsafe { crate::slice::index::into_range_unchecked(len, self).get_unchecked_mut(slice) }
|
||||||
crate::slice::index::into_range_unchecked(slice.len(), self).get_unchecked_mut(slice)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue