diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-06-17 12:53:26 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-06-17 12:53:26 -0300 |
commit | 2f501cd8b909ccf8249b30dedbb15e74012617ca (patch) | |
tree | 8ce1c2ed807a4f93ab59c9e45c4443075cd06517 | |
parent | 21a52ac06f851aceb76bcfc6d1475514e3227b49 (diff) |
Allow unwrapping the raw pointer
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/lib.rs | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml index 8927c06..527af5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ltptr" -version = "0.1.1" +version = "0.1.2" edition = "2021" license = "CC0-1.0" description = "Checked raw pointers." diff --git a/src/lib.rs b/src/lib.rs index 42eb51b..2fcbe12 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -143,6 +143,17 @@ impl<'a, T: ?Sized> ConstLtPtr<'a, T> { _lt: PhantomData, } } + + /// Returns this `ConstLtPtr` as a raw pointer. + /// + /// # Safety + /// + /// This function is unsafe as an advisory: the returned raw pointer loses + /// the lifetime. + #[inline] + pub const unsafe fn as_raw(&self) -> *const T { + self.raw + } } impl<'a, T: ?Sized> MutLtPtr<'a, T> { @@ -160,4 +171,15 @@ impl<'a, T: ?Sized> MutLtPtr<'a, T> { _lt: PhantomData, } } + + /// Returns this `MutLtPtr` as a raw pointer. + /// + /// # Safety + /// + /// This function is unsafe as an advisory: the returned raw pointer loses + /// the lifetime. + #[inline] + pub const unsafe fn as_raw(&self) -> *mut T { + self.raw + } } |