[][src]Struct gdnative::prelude::TypedArray

pub struct TypedArray<T> where
    T: Element
{ /* fields omitted */ }

A reference-counted CoW typed vector using Godot's pool allocator, generic over possible element types.

This type is CoW. The Clone implementation of this type creates a new reference without copying the contents.

When using this type, it's generally better to perform mutations in batch using write, or the append methods, as opposed to push or set, because the latter ones trigger CoW behavior each time they are called.

Implementations

impl<T> TypedArray<T> where
    T: Element
[src]

pub fn new() -> TypedArray<T>[src]

Creates an empty array.

pub fn from_variant_array(array: &VariantArray<Shared>) -> TypedArray<T>[src]

Creates from a VariantArray by making a best effort to convert each variant.

pub fn from_vec(src: Vec<T>) -> TypedArray<T>[src]

Creates a TypedArray moving elements from src.

pub fn push(&mut self, val: T)[src]

Appends an element to the end of the array.

Calling push triggers copy-on-write behavior. To insert a large number of elements, consider using resize and write.

pub fn push_ref(&mut self, val: &T)[src]

Appends an element to the end of the array by reference.

Calling push triggers copy-on-write behavior. To insert a large number of elements, consider using resize and write.

pub fn append(&mut self, src: &TypedArray<T>)[src]

Copies and appends all values in src to the end of the array.

pub fn append_vec(&mut self, src: &mut Vec<T>)[src]

Moves all the elements from src into self, leaving src empty.

Panics

If the resulting length would not fit in i32.

pub fn insert(&mut self, offset: i32, val: T) -> bool[src]

Inserts an element at the given offset and returns true if successful.

pub fn insert_ref(&mut self, offset: i32, val: &T) -> bool[src]

Inserts an element by reference at the given offset and returns true if successful.

pub fn invert(&mut self)[src]

Inverts the order of the elements in the array.

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

Removes an element at the given offset.

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

Changes the size of the array, possibly removing elements or pushing default values.

pub fn get(&self, idx: i32) -> T[src]

Returns a copy of the element at the given offset.

pub fn set(&mut self, idx: i32, val: T)[src]

Sets the value of the element at the given offset.

pub fn set_ref(&mut self, idx: i32, val: &T)[src]

Sets the value of the element at the given offset by reference.

pub fn len(&self) -> i32[src]

Returns the number of elements in the array.

pub fn is_empty(&self) -> bool[src]

Returns true if the container is empty.

pub fn read(&self) -> Aligned<ReadGuard<'_, T>>[src]

Returns a RAII read access into this array.

pub fn write(&mut self) -> Aligned<WriteGuard<'_, T>>[src]

Returns a RAII write access into this array. This triggers CoW once per lock, instead of once each mutation.

impl<T> TypedArray<T> where
    T: Element + Copy
[src]

pub fn from_slice(src: &[T]) -> TypedArray<T>[src]

Creates a new TypedArray by copying from src.

Panics

If the length of src does not fit in i32.

pub fn append_slice(&mut self, src: &[T])[src]

Copies and appends all values in src to the end of the array.

Panics

If the resulting length would not fit in i32.

Trait Implementations

impl<T> Clone for TypedArray<T> where
    T: Element
[src]

impl<T> Debug for TypedArray<T> where
    T: Element + Debug
[src]

impl<T> Default for TypedArray<T> where
    T: Element
[src]

impl<T> Drop for TypedArray<T> where
    T: Element
[src]

impl<T> Eq for TypedArray<T> where
    T: Element + Eq
[src]

impl Export for TypedArray<GodotString>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl Export for TypedArray<Vector2D<f32, UnknownUnit>>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl Export for TypedArray<f32>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl Export for TypedArray<i32>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl Export for TypedArray<Vector3D<f32, UnknownUnit>>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl Export for TypedArray<Color>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl Export for TypedArray<u8>[src]

type Hint = ()

A type-specific hint type that is valid for the type being exported.

impl<T> Extend<T> for TypedArray<T> where
    T: Element
[src]

impl<T> FromIterator<T> for TypedArray<T> where
    T: Element
[src]

impl<T> FromVariant for TypedArray<T> where
    T: Element
[src]

impl<T> NewRef for TypedArray<T> where
    T: Element
[src]

fn new_ref(&self) -> TypedArray<T>[src]

Creates a new reference to this reference-counted instance.

impl<T> PartialEq<TypedArray<T>> for TypedArray<T> where
    T: Element + PartialEq<T>, 
[src]

impl<T> ToVariant for TypedArray<T> where
    T: Element
[src]

impl<T> ToVariantEq for TypedArray<T> where
    T: Element + Eq
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for TypedArray<T> where
    <T as Element>::SysArray: RefUnwindSafe

impl<T> Send for TypedArray<T> where
    <T as Element>::SysArray: Send

impl<T> Sync for TypedArray<T> where
    <T as Element>::SysArray: Sync

impl<T> Unpin for TypedArray<T> where
    <T as Element>::SysArray: Unpin

impl<T> UnwindSafe for TypedArray<T> where
    <T as Element>::SysArray: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> OwnedToVariant for T where
    T: ToVariant
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.