Function vm_memory::volatile_memory::compute_offset

source ·
pub fn compute_offset(base: usize, offset: usize) -> Result<usize>
Expand description

Convenience function for computing base + offset.

§Errors

Returns Err(Error::Overflow) in case base + offset exceeds usize::MAX.

§Examples

assert_eq!(108, compute_offset(100, 8).unwrap());
assert!(compute_offset(std::usize::MAX, 6).is_err());