/// a mutable "slice" (bundle of pointer and length). The main goal of this type is passing MIRI /// with stacked borrows. In particular, storing a standard slice in data structures violates the /// stacked borrows rule when that slice is deallocated. By only materializing the slice when /// needed for data access, hence bounding the lifetime more tightly, this restriction is circumvented. #[derive(Debug)] pub(crate) struct WeakSliceMut<'a, T> {
ptr: *mut T,
len: usize,
_marker: PhantomData<&'a mut [T]>,
}
impl<'a, T> WeakSliceMut<'a, T> { /// # Safety /// /// The arguments must satisfy the requirements of [`core::slice::from_raw_parts_mut`]. The /// difference versus a slice is that the slice requirements are only enforced when a slice is /// needed, so in practice we mostly get the bounds checking and other convenient slice APIs, /// without the exact correctness constraints of a rust core/std slice. pub(crate) unsafefn from_raw_parts_mut(ptr: *mut T, len: usize) -> Self { Self {
ptr,
len,
_marker: PhantomData,
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.