Struct fuel_vm::interpreter::MemoryRange
source · pub struct MemoryRange(_);
Expand description
Memory range representation for the VM, checked to be in-bounds on construction.
Implementations§
source§impl MemoryRange
impl MemoryRange
sourcepub fn new<A: ToAddr, B: ToAddr>(
address: A,
size: B
) -> Result<Self, RuntimeError>
pub fn new<A: ToAddr, B: ToAddr>( address: A, size: B ) -> Result<Self, RuntimeError>
Create a new memory range represented as [address, address + size[
.
sourcepub fn new_const<A: ToAddr, const SIZE: usize>(
address: A
) -> Result<Self, RuntimeError>
pub fn new_const<A: ToAddr, const SIZE: usize>( address: A ) -> Result<Self, RuntimeError>
Create a new const sized memory range.
sourcepub fn shrink_end(&mut self, by: usize)
pub fn shrink_end(&mut self, by: usize)
This function is safe because it is only used to shrink the range and worst case the range will be empty.
sourcepub fn grow_start(&mut self, by: usize)
pub fn grow_start(&mut self, by: usize)
This function is safe because it is only used to grow the range and worst case the range will be empty.
Methods from Deref<Target = Range<usize>>§
1.35.0 · sourcepub fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
pub fn contains<U>(&self, item: &U) -> boolwhere Idx: PartialOrd<U>, U: PartialOrd<Idx> + ?Sized,
Returns true
if item
is contained in the range.
Examples
assert!(!(3..5).contains(&2));
assert!( (3..5).contains(&3));
assert!( (3..5).contains(&4));
assert!(!(3..5).contains(&5));
assert!(!(3..3).contains(&3));
assert!(!(3..2).contains(&3));
assert!( (0.0..1.0).contains(&0.5));
assert!(!(0.0..1.0).contains(&f32::NAN));
assert!(!(0.0..f32::NAN).contains(&0.5));
assert!(!(f32::NAN..1.0).contains(&0.5));
1.47.0 · sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the range contains no items.
Examples
assert!(!(3..5).is_empty());
assert!( (3..3).is_empty());
assert!( (3..2).is_empty());
The range is empty if either side is incomparable:
assert!(!(3.0..5.0).is_empty());
assert!( (3.0..f32::NAN).is_empty());
assert!( (f32::NAN..5.0).is_empty());
Trait Implementations§
source§impl Clone for MemoryRange
impl Clone for MemoryRange
source§fn clone(&self) -> MemoryRange
fn clone(&self) -> MemoryRange
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MemoryRange
impl Debug for MemoryRange
source§impl Default for MemoryRange
impl Default for MemoryRange
source§impl Deref for MemoryRange
impl Deref for MemoryRange
source§impl Hash for MemoryRange
impl Hash for MemoryRange
source§impl PartialEq<MemoryRange> for MemoryRange
impl PartialEq<MemoryRange> for MemoryRange
source§fn eq(&self, other: &MemoryRange) -> bool
fn eq(&self, other: &MemoryRange) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for MemoryRange
impl StructuralEq for MemoryRange
impl StructuralPartialEq for MemoryRange
Auto Trait Implementations§
impl RefUnwindSafe for MemoryRange
impl Send for MemoryRange
impl Sync for MemoryRange
impl Unpin for MemoryRange
impl UnwindSafe for MemoryRange
Blanket Implementations§
source§impl<T> AnyDebug for Twhere
T: Any + Debug,
impl<T> AnyDebug for Twhere T: Any + Debug,
source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Returns a reference to the underlying type as
Any
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more