Struct Array

Source
pub struct Array { /* private fields */ }
Expand description

Describes a contiguous area in memory composed of Words.

Implementations§

Source§

impl Array

Source

pub fn new(size: usize) -> Self

Creates a new array composed of zeros.

Source

pub fn from(arr: &[Word]) -> Self

Creates a new array from a slice of Words.

Source

pub fn sub(&self, ignore_start: Address, ignore_end: Address) -> Self

Gets a subset of the current array.

Source

pub fn sub_from_start(&self, ignore_end: Address) -> Self

Gets a subset of the current array with its end trimmed.

Source

pub fn sub_from_end(&self, ignore_start: Address) -> Self

Gets a subset of the current array with its start trimmed.

Source

pub fn split(&self, cesure: Address) -> (Array, Array)

Returns ([..cesure], [cesure..]).

Source

pub fn as_slice(&self) -> &[Word]

Returns a slice that shares the raw Words data.

Source

pub fn as_mut_slice(&mut self) -> &mut [Word]

Returns a slice that shares the raw Words data.

Source

pub fn next(&self, index: &mut Address) -> Option<Word>

Returns Some(Word) at the corresponding index.

Source

pub fn iter(&self) -> Iter<'_, Word>

Returns an iterator that gives immutable references to the elements in the collection in sequence.

Source

pub fn len(&self) -> usize

Returns the number of words in the array.

Source

pub fn is_empty(&self) -> bool

Returns true if the array contains no elements.

Source

pub fn push(&mut self, value: Word)

Appends an element to the end of the array.

Source

pub fn insert(&mut self, address: Address, value: Word)

Inserts an element to the array at a specific position.

Assumes that ‘address’ can be converted to a position in the array.

Source

pub fn remove(&mut self, index: Address) -> Word

Removes and returns the element at position ‘index’ in the array.

Assumes that ‘index’ can be converted to a valid position in the array.

Source

pub fn merge(&mut self, with: &Array)

Merges the current array with a borrowed array.

Source

pub fn extract(&self, area: Area) -> Array

Extract an array covering a whole area.

Source

pub fn extract_word(&self, area: Area, cursor: Address) -> Word

Extract one word inside an area from the array.

Source

pub fn next_word(&self, cursor: Cursor) -> (Word, Cursor)

Extract one word from a cursor reference and advances it.

Trait Implementations§

Source§

impl Clone for Array

Source§

fn clone(&self) -> Array

Returns a duplicate 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 Debug for Array

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Array

Source§

fn default() -> Array

Returns the “default value” for a type. Read more
Source§

impl Index<Address> for Array

Source§

type Output = Word

The returned type after indexing.
Source§

fn index(&self, index: Address) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Address> for Array

Source§

fn index_mut(&mut self, index: Address) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IntoIterator for Array

Source§

type Item = Word

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<Array as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl Freeze for Array

§

impl RefUnwindSafe for Array

§

impl Send for Array

§

impl Sync for Array

§

impl Unpin for Array

§

impl UnwindSafe for Array

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.