[−][src]Struct gdnative_core::core_types::variant_array::VariantArray
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 Variant
s 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
impl<Access: ThreadAccess> VariantArray<Access>
[src]
Operations allowed on all arrays at any point in time.
pub fn set<T: OwnedToVariant>(&self, idx: i32, val: T)
[src]
Sets the value of the element at the given offset.
pub fn get(&self, idx: i32) -> Variant
[src]
Returns a copy of the element at the given offset.
pub unsafe fn get_ref(&self, idx: i32) -> &Variant
[src]
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.
pub unsafe fn get_mut_ref(&self, idx: i32) -> &mut Variant
[src]
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.
pub fn count<T: ToVariant>(&self, val: T) -> i32
[src]
pub fn is_empty(&self) -> bool
[src]
Returns true
if the VariantArray
contains no elements.
pub fn len(&self) -> i32
[src]
Returns the number of elements in the array.
pub fn find<T: ToVariant>(&self, what: T, from: i32) -> i32
[src]
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.
pub fn contains<T: ToVariant>(&self, what: T) -> bool
[src]
Returns true if the VariantArray
contains the specified value.
pub fn rfind<T: ToVariant>(&self, what: T, from: i32) -> i32
[src]
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.
pub fn find_last<T: ToVariant>(&self, what: T) -> i32
[src]
Searches the array in reverse order for a value.
Returns its index or -1
if not found.
pub fn invert(&self)
[src]
Inverts the order of the elements in the array.
pub fn hash(&self) -> i32
[src]
Return a hashed i32 value representing the array contents.
pub fn sort(&self)
[src]
pub fn duplicate(&self) -> VariantArray<Unique>
[src]
Create a copy of the array.
This creates a new array and is not a cheap reference count increment.
pub fn iter(&self) -> Iter<'_, Access>ⓘ
[src]
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.
impl<Access: LocalThreadAccess> VariantArray<Access>
[src]
Operations allowed on Dictionaries that can only be referenced to from the current thread.
pub fn clear(&self)
[src]
Clears the array, resizing to 0.
pub fn remove(&self, idx: i32)
[src]
Removes the element at idx
.
pub fn erase<T: ToVariant>(&self, val: T)
[src]
Removed the first occurrence of val
.
pub fn resize(&self, size: i32)
[src]
Resizes the array, filling with Nil
if necessary.
pub fn push<T: OwnedToVariant>(&self, val: T)
[src]
Appends an element at the end of the array.
pub fn pop(&self) -> Variant
[src]
Removes an element at the end of the array.
pub fn push_front<T: OwnedToVariant>(&self, val: T)
[src]
Appends an element to the front of the array.
pub fn pop_front(&self) -> Variant
[src]
Removes an element at the front of the array.
pub fn insert<T: OwnedToVariant>(&self, at: i32, val: T)
[src]
Insert a new int at a given position in the array.
impl<Access: NonUniqueThreadAccess> VariantArray<Access>
[src]
Operations allowed on non-unique arrays.
pub unsafe fn assume_unique(self) -> VariantArray<Unique>
[src]
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.
impl VariantArray<Unique>
[src]
Operations allowed on unique arrays.
pub fn new() -> Self
[src]
Creates an empty VariantArray
.
pub fn into_shared(self) -> VariantArray<Shared>
[src]
Put this array under the "shared" access type.
pub fn into_thread_local(self) -> VariantArray<ThreadLocal>
[src]
Put this array under the "thread-local" access type.
impl VariantArray<Shared>
[src]
Operations allowed on arrays that might be shared between different threads.
pub fn new_shared() -> Self
[src]
Create a new shared array.
pub unsafe fn clear(&self)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Clears the array, resizing to 0.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn remove(&self, idx: i32)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Removes the element at idx
.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn erase<T: ToVariant>(&self, val: T)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Removed the first occurrence of val
.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn resize(&self, size: i32)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Resizes the array, filling with Nil
if necessary.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn push<T: OwnedToVariant>(&self, val: T)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Appends an element at the end of the array.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn pop(&self) -> Variant
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Removes an element at the end of the array.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn push_front<T: OwnedToVariant>(&self, val: T)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Appends an element to the front of the array.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn pop_front(&self) -> Variant
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Removes an element at the front of the array.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
pub unsafe fn insert<T: OwnedToVariant>(&self, at: i32, val: T)
[src]
Care should be used when mutating shared variant collections. Prefer ThreadLocal
or Unique
collections unless you're absolutely sure that you want this. You may use assume_unique to convert this to a Unique
collection if you are sure that this is in fact the only reference.
Insert a new int at a given position in the array.
Safety
Generally, it's not recommended to mutate variant collections that may be shared. Prefer
ThreadLocal
or Unique
collections instead. If you're sure that the current reference
is unique, you may use assume_unique
to convert it to a Unique
collection. You may subsequently use into_thread_local
to
convert it to a ThreadLocal
one.
It is only safe to perform operations that may allocate on a shared collection when no other thread may access the underlying collection during the call.
impl VariantArray<ThreadLocal>
[src]
Operations allowed on Dictionaries that may only be shared on the current thread.
pub fn new_thread_local() -> Self
[src]
Create a new thread-local array.
Trait Implementations
impl<Access: ThreadAccess> Debug for VariantArray<Access>
[src]
impl Default for VariantArray<Unique>
[src]
impl Default for VariantArray<Shared>
[src]
impl Default for VariantArray<ThreadLocal>
[src]
impl<Access: ThreadAccess> Drop for VariantArray<Access>
[src]
impl Export for VariantArray
[src]
type Hint = ()
A type-specific hint type that is valid for the type being exported.
fn export_info(_hint: Option<Self::Hint>) -> ExportInfo
[src]
impl<T: ToVariant, Access: LocalThreadAccess> Extend<T> for VariantArray<Access>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<T: ToVariant> FromIterator<T> for VariantArray<Unique>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
impl FromVariant for VariantArray<Shared>
[src]
fn from_variant(variant: &Variant) -> Result<Self, FromVariantError>
[src]
impl<'a, Access: ThreadAccess> IntoIterator for &'a VariantArray<Access>
[src]
type Item = Variant
The type of the elements being iterated over.
type IntoIter = Iter<'a, Access>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl IntoIterator for VariantArray<Unique>
[src]
type Item = Variant
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<Access: NonUniqueThreadAccess> NewRef for VariantArray<Access>
[src]
impl OwnedToVariant for VariantArray<Unique>
[src]
fn owned_to_variant(self) -> Variant
[src]
impl ToVariant for VariantArray<Shared>
[src]
fn to_variant(&self) -> Variant
[src]
Auto Trait Implementations
impl<Access> RefUnwindSafe for VariantArray<Access> where
Access: RefUnwindSafe,
Access: RefUnwindSafe,
impl<Access> Send for VariantArray<Access> where
Access: Send,
Access: Send,
impl<Access> Sync for VariantArray<Access> where
Access: Sync,
Access: Sync,
impl<Access> Unpin for VariantArray<Access> where
Access: Unpin,
Access: Unpin,
impl<Access> UnwindSafe for VariantArray<Access> where
Access: UnwindSafe,
Access: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> OwnedToVariant for T where
T: ToVariant,
[src]
T: ToVariant,
fn owned_to_variant(Self) -> Variant
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,