pub struct Dictionary<Own = Shared>where
    Own: Ownership,
{ /* private fields */ }
Expand description

A reference-counted Dictionary of Variant key-value pairs.

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 Ownership 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 Dictionaries at any point in time.

Returns true if the Dictionary contains no elements.

Returns the number of elements in the Dictionary.

Returns true if the Dictionary contains the specified key.

Returns true if the Dictionary has all of the keys in the given array.

Returns a copy of the value corresponding to the key if it exists.

Returns a copy of the value corresponding to the key, or default if it doesn’t exist

Returns a copy of the element corresponding to the key, or Nil if it doesn’t exist. Shorthand for self.get_or(key, Variant::nil()).

Update an existing element corresponding to the key.

Panics

Panics if the entry for key does not exist.

Returns a reference to the value corresponding to the key, inserting a Nil value first if it does not exist.

Safety

The returned reference is invalidated if the same container is mutated through another reference, and other references may be invalidated if the entry does not already exist (which causes this function to insert Nil and thus possibly re-allocate).

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

Returns a mutable reference to the value corresponding to the key, inserting a Nil value first if it does not exist.

Safety

The returned reference is invalidated if the same container is mutated through another reference, and other references may be invalidated if the key does not already exist (which causes this function to insert Nil and thus possibly re-allocate). It is also possible to create two mutable references to the same memory location if the same key is provided, causing undefined behavior.

Returns a GodotString of the Dictionary.

Returns an array of the keys in the Dictionary.

Returns an array of the values in the Dictionary.

Return a hashed i32 value representing the dictionary’s contents.

Returns an iterator through all key-value pairs in the Dictionary.

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

Create a copy of the dictionary.

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

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

Create a new shared dictionary.

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

Create a new thread-local dictionary.

Operations allowed on Dictionaries that are not unique.

Assume that this is the only reference to this dictionary, 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 Dictionaries that can only be referenced to from the current thread.

Inserts or updates the value of the element corresponding to the key.

Erase a key-value pair in the Dictionary by the specified key.

Clears the Dictionary, removing all key-value pairs.

Operations allowed on unique Dictionaries.

Creates an empty Dictionary.

Put this dictionary under the “shared” access type.

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

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
Converts to this type from the input type.
Converts to this type from the input type.
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.