pub struct Array { /* private fields */ }Expand description
An array data structure that supports various operations.
Implementations§
Source§impl Array
impl Array
Sourcepub fn add_range(&mut self, other: &Array)
pub fn add_range(&mut self, other: &Array)
Adds all items from another array to the end of this array.
§Arguments
other- Another array object.
Sourcepub fn remove_from(&mut self, other: &Array)
pub fn remove_from(&mut self, other: &Array)
Removes all items from this array that are also in another array.
§Arguments
other- Another array object.
Sourcepub fn shrink(&mut self)
pub fn shrink(&mut self)
Removes any empty slots from the end of the array. This method is used to release the unused memory this array holds.
Sourcepub fn swap(&mut self, index_a: i32, index_b: i32)
pub fn swap(&mut self, index_a: i32, index_b: i32)
Swaps the items at two given indices.
§Arguments
index_a- The first index.index_b- The second index.
Sourcepub fn fast_remove_at(&mut self, index: i32) -> bool
pub fn fast_remove_at(&mut self, index: i32) -> bool
Source§impl Array
impl Array
Sourcepub fn set<'a, T>(&mut self, index: i32, v: T)where
T: IntoValue<'a>,
pub fn set<'a, T>(&mut self, index: i32, v: T)where
T: IntoValue<'a>,
Sets the item at the given index.
§Arguments
index- The index to set, should be 0 based.item- The new item value.
Sourcepub fn random_object(&self) -> Option<Value>
pub fn random_object(&self) -> Option<Value>
A random item from the array.
Sourcepub fn insert<'a, T>(&mut self, index: i32, v: T)where
T: IntoValue<'a>,
pub fn insert<'a, T>(&mut self, index: i32, v: T)where
T: IntoValue<'a>,
Inserts an item at the given index, shifting other items to the right.
§Arguments
index- The index to insert at.item- The item to insert.
Sourcepub fn remove_last(&mut self) -> Option<Value>
pub fn remove_last(&mut self) -> Option<Value>
Removes and returns the last item in the array.
§Returns
Option<Value>- The last item removed from the array.
Trait Implementations§
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> 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