pub struct VariantArray<Own = Shared>where
    Own: Ownership,
{ /* 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.

Generic methods on this type performs Variant conversion every time. This could be significant for complex structures. Users may convert arguments to Variants before calling to avoid this behavior if necessary.

Safety

This is a reference-counted collection with “interior mutability” in Rust parlance. To enforce that the official thread-safety guidelines are followed this type uses the typestate pattern. The typestate Access tracks whether there is thread-local or unique access (where pretty much all operations are safe) or whether the value might be “shared”, in which case not all operations are safe.

Implementations

Operations allowed on all arrays at any point in time.

Sets the value of the element at the given offset.

Returns a copy of the element at the given offset.

Returns a reference to the element at the given offset.

Safety

The returned reference is invalidated if the same container is mutated through another reference.

Variant is reference-counted and thus cheaply cloned. Consider using get instead.

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

Safety

The returned reference is invalidated if the same container is mutated through another reference. It is possible to create two mutable references to the same memory location if the same idx is provided, causing undefined behavior.

Returns true if the VariantArray contains no elements.

Returns the number of elements in the array.

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.

Returns true if the VariantArray contains the specified value.

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.

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

Inverts the order of the elements in the array.

Return a hashed i32 value representing the array contents.

Create a copy of the array.

This creates a new array and is not a cheap reference count increment.

Create a deep copy of the array.

This creates a new array and is not a cheap reference count increment.

Returns an iterator through all values in the VariantArray.

VariantArray is reference-counted and have interior mutability in Rust parlance. Modifying the same underlying collection while observing the safety assumptions will not violate memory safely, but may lead to surprising behavior in the iterator.

Operations allowed on Dictionaries that can only be referenced to from the current thread.

Clears the array, resizing to 0.

Removes the element at idx.

Removed the first occurrence of val.

Resizes the array, filling with Nil if necessary.

Appends an element at the end of the array.

Removes an element at the end of the array.

Appends an element to the front of the array.

Removes an element at the front of the array.

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

Operations allowed on non-unique arrays.

Assume that this is the only reference to this array, on which operations that change the container size can be safely performed.

Safety

It isn’t thread-safe to perform operations that change the container size from multiple threads at the same time. Creating multiple Unique references to the same collections, or violating the thread-safety guidelines in non-Rust code will cause undefined behavior.

Operations allowed on unique arrays.

Creates an empty VariantArray.

Put this array under the “shared” access type.

Put this array under the “thread-local” access type.

Operations allowed on arrays that might be shared between different threads.

Create a new shared array.

Operations allowed on Dictionaries that may only be shared on the current thread.

Create a new thread-local array.

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Returns the “default value” for a type. Read more
Executes the destructor for this type. Read more
A type-specific hint type that is valid for the type being exported. Read more
Returns ExportInfo given an optional typed hint.
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
Creates a new reference to the underlying object.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.