Struct VariantArray

Source
pub struct VariantArray(/* private fields */);
Expand description

A reference-counted Variant vector. Godot’s generic array data type. Negative indices can be used to count from the right.

Implementations§

Source§

impl VariantArray

Source

pub fn new() -> VariantArray

Creates an empty VariantArray.

Source

pub fn set(&mut self, idx: i32, val: &Variant)

Sets the value of the element at the given offset.

Source

pub fn get_val(&mut self, idx: i32) -> Variant

Returns a copy of the element at the given offset.

Source

pub fn get_ref(&self, idx: i32) -> &Variant

Returns a reference to the element at the given offset.

Source

pub fn get_mut_ref(&mut self, idx: i32) -> &mut Variant

Returns a mutable reference to the element at the given offset.

Source

pub fn count(&mut self, val: &Variant) -> i32

Source

pub fn clear(&mut self)

Clears the array, resizing to 0.

Source

pub fn remove(&mut self, idx: i32)

Source

pub fn erase(&mut self, val: &Variant)

Source

pub fn is_empty(&self) -> bool

Returns true if the VariantArray contains no elements.

Source

pub fn len(&self) -> i32

Returns the number of elements in the array.

Source

pub fn push(&mut self, val: &Variant)

Appends an element at the end of the array.

Source

pub fn pop(&mut self) -> Variant

Removes an element at the end of the array.

Source

pub fn push_front(&mut self, val: &Variant)

Appends an element to the front of the array.

Source

pub fn pop_front(&mut self) -> Variant

Removes an element at the front of the array.

Source

pub fn insert(&mut self, at: i32, val: &Variant)

Insert a new int at a given position in the array.

Source

pub fn find(&self, what: &Variant, from: i32) -> i32

Searches the array for a value and returns its index. Pass an initial search index as the second argument. Returns -1 if value is not found.

Source

pub fn contains(&self, what: &Variant) -> bool

Returns true if the VariantArray contains the specified value.

Source

pub fn resize(&mut self, size: i32)

Source

pub fn rfind(&self, what: &Variant, from: i32) -> i32

Searches the array in reverse order. Pass an initial search index as the second argument. If negative, the start index is considered relative to the end of the array.

Source

pub fn find_last(&self, what: &Variant) -> i32

Searches the array in reverse order for a value. Returns its index or -1 if not found.

Source

pub fn invert(&mut self)

Inverts the order of the elements in the array.

Source

pub fn hash(&self) -> i32

Return a hashed i32 value representing the array contents.

Source

pub fn sort(&mut self)

Source

pub fn new_ref(&self) -> VariantArray

Trait Implementations§

Source§

impl Default for VariantArray

Source§

fn default() -> VariantArray

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

impl Drop for VariantArray

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'l> From<&'l VariantArray> for Variant

Source§

fn from(val: &'l VariantArray) -> Variant

Converts to this type from the input type.
Source§

impl ToVariant for VariantArray

Auto Trait Implementations§

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> 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, 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.