Skip to content

Commit

Permalink
add from_slice to VirtAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
Wasabi375 committed Oct 13, 2023
1 parent 9d1e486 commit 135d18a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ impl VirtAddr {
Self::new(ptr as u64)
}

/// Creates a virtual address from the given slice.
#[cfg(target_pointer_width = "64")]
pub fn from_slice<T>(slice: &[T]) -> Self {
Self::new(slice as *const [T] as *const T as u64)
}

/// Converts the address to a raw pointer.
#[cfg(target_pointer_width = "64")]
#[inline]
Expand Down

0 comments on commit 135d18a

Please sign in to comment.