#[derive(Debug)] pubstruct Window<'a> { // the full window allocation. This is longer than w_size so that operations don't need to // perform bounds checks.
buf: WeakSliceMut<'a, u8>,
window_bits: usize,
}
impl<'a> Window<'a> { pubunsafefn from_raw_parts(ptr: *mut u8, window_bits: usize) -> Self { let len = (1 << window_bits) * 2; let buf = unsafe { WeakSliceMut::from_raw_parts_mut(ptr, len) };
/// Returns a shared reference to the filled portion of the buffer. #[inline] pubfn filled(&self) -> &[u8] { // SAFETY: `self.buf` has been initialized for at least `filled` elements unsafe { core::slice::from_raw_parts(self.buf.as_ptr().cast(), self.buf.len()) }
}
/// Returns a mutable reference to the filled portion of the buffer. #[inline] pubfn filled_mut(&mutself) -> &mut [u8] { // SAFETY: `self.buf` has been initialized for at least `filled` elements unsafe { core::slice::from_raw_parts_mut(self.buf.as_mut_ptr().cast(), self.buf.len()) }
}
/// # Safety /// /// `src` must point to `range.end - range.start` valid (initialized!) bytes pubunsafefn copy_and_initialize(&mutself, range: core::ops::Range<usize>, src: *const u8) { let (start, end) = (range.start, range.end);
let dst = self.buf.as_mut_slice()[range].as_mut_ptr(); unsafe { core::ptr::copy_nonoverlapping(src, dst, end - start) };
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-08-27)
¤
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.