diff --git a/memory_addr/src/addr.rs b/memory_addr/src/addr.rs index de9996f..30450c9 100644 --- a/memory_addr/src/addr.rs +++ b/memory_addr/src/addr.rs @@ -300,11 +300,23 @@ impl VirtAddr { self.0 as *const u8 } + /// Converts the virtual address to a raw pointer of a specific type. + #[inline] + pub const fn as_ptr_of(self) -> *const T { + self.0 as *const T + } + /// Converts the virtual address to a mutable raw pointer. #[inline] pub const fn as_mut_ptr(self) -> *mut u8 { self.0 as *mut u8 } + + /// Converts the virtual address to a mutable raw pointer of a specific type. + #[inline] + pub const fn as_mut_ptr_of(self) -> *mut T { + self.0 as *mut T + } } /// Alias for [`PhysAddr::from_usize`].