Skip to content

Commit

Permalink
add two more functions to VirtAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
aarkegz committed Aug 21, 2024
1 parent 7777cb8 commit 1ce711c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions memory_addr/src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(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<T>(self) -> *mut T {
self.0 as *mut T
}
}

/// Alias for [`PhysAddr::from_usize`].
Expand Down

0 comments on commit 1ce711c

Please sign in to comment.