Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read helpers #5

Merged
merged 17 commits into from
Nov 6, 2023
Prev Previous commit
Next Next commit
MaybeUnint -> MaybeUninit
fu5ha committed Nov 6, 2023
commit c4288b539ede0d1321f9a320b2f7b80b0bc8ce0e
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ pub use read::*;
/// trait for the extra flexibility having a trait we own provides: namely, the ability
/// to implement it on foreign types.
///
/// It is implemented for a couple of built-in slab providers, as well as for `[MaybeUnint<u8>]`,
/// It is implemented for a couple of built-in slab providers, as well as for `[MaybeUninit<u8>]`,
/// but the idea is that you can also implement this for your own data structure which can
/// serve as a slab and then use that structure directly with `presser`'s helpers.
///
@@ -262,7 +262,7 @@ pub unsafe trait Slab {
{
let maybe_uninit_slice = &self.as_maybe_uninit_bytes()[range];
// SAFETY: same requirements as function-level safety assuming the requirements
// for creating `self` are met since `MaybeUnint<T>` has same layout as `T`
// for creating `self` are met since `MaybeUninit<T>` has same layout as `T`
unsafe {
core::slice::from_raw_parts(
maybe_uninit_slice.as_ptr().cast(),
@@ -294,7 +294,7 @@ pub unsafe trait Slab {
{
let maybe_uninit_slice = &mut self.as_maybe_uninit_bytes_mut()[range];
// SAFETY: same requirements as function-level safety assuming the requirements
// for creating `self` are met since `MaybeUnint<T>` has same layout as `T`
// for creating `self` are met since `MaybeUninit<T>` has same layout as `T`
unsafe {
core::slice::from_raw_parts_mut(
maybe_uninit_slice.as_mut_ptr().cast(),