lower msrv to 1.32.0

going back further btw
This commit is contained in:
nora 2022-04-06 19:34:22 +02:00
parent 75fd92489d
commit ee7e477006
2 changed files with 26 additions and 17 deletions

View file

@ -11,6 +11,7 @@ license = "MIT"
keywords = ["unsafe", "pointer", "bitpacking", "provenance", "tagging"] keywords = ["unsafe", "pointer", "bitpacking", "provenance", "tagging"]
categories = ["data-structures", "memory-management", "no-std"] categories = ["data-structures", "memory-management", "no-std"]
include = ["Cargo.toml", "LICENSE", "src", "README.md"] include = ["Cargo.toml", "LICENSE", "src", "README.md"]
rust-version = "1.32.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,6 +1,5 @@
#![no_std] #![no_std]
#![warn(rust_2018_idioms)] #![warn(rust_2018_idioms)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(missing_docs)] #![warn(missing_docs)]
//! A crate for stuffing things into a pointer. //! A crate for stuffing things into a pointer.
@ -146,10 +145,13 @@ where
/// Get the pointer data, or `None` if it contains extra data /// Get the pointer data, or `None` if it contains extra data
pub fn get_ptr(&self) -> Option<*mut T> { pub fn get_ptr(&self) -> Option<*mut T> {
self.is_extra().not().then(|| { match self.is_extra().not() {
true => {
// SAFETY: We have done a check that it's not extra // SAFETY: We have done a check that it's not extra
unsafe { self.get_ptr_unchecked() } unsafe { Some(self.get_ptr_unchecked()) }
}) }
false => None,
}
} }
/// Get the unstuffed pointer data from the stuffed pointer, assuming that the `StuffedPtr` /// Get the unstuffed pointer data from the stuffed pointer, assuming that the `StuffedPtr`
@ -165,10 +167,13 @@ where
/// Get owned extra data from this, or `None` if it contains pointer data /// Get owned extra data from this, or `None` if it contains pointer data
pub fn into_extra(self) -> Option<S::Extra> { pub fn into_extra(self) -> Option<S::Extra> {
self.is_extra().then(|| { match self.is_extra() {
true => {
// SAFETY: We checked that it contains an extra above // SAFETY: We checked that it contains an extra above
unsafe { self.into_extra_unchecked() } unsafe { Some(self.into_extra_unchecked()) }
}) }
false => None,
}
} }
/// Turn this pointer into extra data. /// Turn this pointer into extra data.
@ -176,7 +181,7 @@ where
/// `StuffedPtr` must contain extra data and not pointer /// `StuffedPtr` must contain extra data and not pointer
pub unsafe fn into_extra_unchecked(self) -> S::Extra { pub unsafe fn into_extra_unchecked(self) -> S::Extra {
// SAFETY: `self` is consumed and forgotten after this call // SAFETY: `self` is consumed and forgotten after this call
let extra = unsafe { self.get_extra_unchecked() }; let extra = self.get_extra_unchecked();
mem::forget(self); mem::forget(self);
extra extra
} }
@ -185,10 +190,13 @@ where
/// # Safety /// # Safety
/// The caller must guarantee that only ever on `Extra` exists if `Extra: !Copy` /// The caller must guarantee that only ever on `Extra` exists if `Extra: !Copy`
pub unsafe fn get_extra(&self) -> Option<S::Extra> { pub unsafe fn get_extra(&self) -> Option<S::Extra> {
self.is_extra().then(|| { match self.is_extra() {
true => {
// SAFETY: We checked that it contains extra above, the caller guarantees the rest // SAFETY: We checked that it contains extra above, the caller guarantees the rest
unsafe { self.get_extra_unchecked() } Some(self.get_extra_unchecked())
}) }
false => None,
}
} }
/// Get extra data from this /// Get extra data from this
@ -197,7 +205,7 @@ where
/// and the caller must guarantee that only ever on `Extra` exists if `Extra: !Copy` /// and the caller must guarantee that only ever on `Extra` exists if `Extra: !Copy`
pub unsafe fn get_extra_unchecked(&self) -> S::Extra { pub unsafe fn get_extra_unchecked(&self) -> S::Extra {
let data = self.addr(); let data = self.addr();
unsafe { S::extract_extra(data) } S::extract_extra(data)
} }
fn addr(&self) -> B { fn addr(&self) -> B {
@ -227,7 +235,7 @@ where
/// Must contain extra data and not pointer data, /// Must contain extra data and not pointer data,
pub unsafe fn copy_extra_unchecked(&self) -> S::Extra { pub unsafe fn copy_extra_unchecked(&self) -> S::Extra {
// SAFETY: `S::Extra: Copy`, and the caller guarantees that it's extra // SAFETY: `S::Extra: Copy`, and the caller guarantees that it's extra
unsafe { self.get_extra_unchecked() } self.get_extra_unchecked()
} }
} }
@ -336,7 +344,7 @@ where
} else { } else {
// SAFETY: Checked above // SAFETY: Checked above
let ptr = unsafe { self.get_ptr_unchecked() }; let ptr = unsafe { self.get_ptr_unchecked() };
core::ptr::hash(ptr, state); ptr.hash(state);
} }
} }
} }