x86_64 icon indicating copy to clipboard operation
x86_64 copied to clipboard

Implement conversion traits for PhysAddr and VirtAddr

Open mikeleany opened this issue 2 years ago • 6 comments

Implements the following conversions:

  • TryFrom<u64> for VirtAddr and PhysAddr
  • TryFrom<usize> for VirtAddr and PhysAddr
  • From<u32> for VirtAddr and PhysAddr
  • TryFrom<*const T> for VirtAddr
  • TryFrom<*mut T> for VirtAddr
  • From<&T> for VirtAddr
  • From<&mut T> for VirtAddr
  • From<VirtAddr> for u64, *const T and *mut T
  • From<PhysAddr> for u64

I restricted pointer and usize conversions with #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]. This restriction isn't strictly necessary for TryFrom, but without it we would need a different error type than what try_new uses.

Closes #268. See also #293 (comment) by @josephlr.

mikeleany avatar Oct 23 '22 02:10 mikeleany