pub struct CheckedMemConstLen<const LEN: usize>(_);
Expand description

A range of memory that has been checked that it fits into the VM memory.

Implementations§

source§

impl<const LEN: usize> CheckedMemConstLen<LEN>

source

pub fn new(address: Word) -> Result<Self, RuntimeError>

Create a new const sized memory range.

source

pub fn read(self, memory: &[u8; 67108864]) -> &[u8; LEN]

Get the memory slice for this range.

source

pub fn write(self, memory: &mut [u8; 67108864]) -> &mut [u8; LEN]

Get the mutable memory slice for this range.

Methods from Deref<Target = MemoryRange>§

source

pub fn is_empty(&self) -> bool

Return true if the length is 0.

source

pub fn usizes(&self) -> Range<usize>

Convert to a raw usize range.

source

pub fn words(&self) -> Range<Word>

Convert to a raw Word range.

source

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.

source

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 · source

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 · source

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<const LEN: usize> Clone for CheckedMemConstLen<LEN>

source§

fn clone(&self) -> CheckedMemConstLen<LEN>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<const LEN: usize> Deref for CheckedMemConstLen<LEN>

§

type Target = MemoryRange

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<const LEN: usize> DerefMut for CheckedMemConstLen<LEN>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<const LEN: usize> RefUnwindSafe for CheckedMemConstLen<LEN>

§

impl<const LEN: usize> Send for CheckedMemConstLen<LEN>

§

impl<const LEN: usize> Sync for CheckedMemConstLen<LEN>

§

impl<const LEN: usize> Unpin for CheckedMemConstLen<LEN>

§

impl<const LEN: usize> UnwindSafe for CheckedMemConstLen<LEN>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> StorageAsMut for T

source§

fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

source§

fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

source§

impl<T> StorageAsRef for T

source§

fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

source§

fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V