Struct runestick::Object[][src]

#[repr(transparent)]
pub struct Object { /* fields omitted */ }
Expand description

Struct representing a dynamic anonymous object.

Examples

let mut object = runestick::Object::new();
assert!(object.is_empty());

object.insert_value(String::from("foo"), 42)?;
object.insert_value(String::from("bar"), true)?;
assert_eq!(2, object.len());

assert_eq!(Some(42), object.get_value("foo")?);
assert_eq!(Some(true), object.get_value("bar")?);
assert_eq!(None::<bool>, object.get_value("baz")?);

Implementations

Construct a new object.

Construct a new object with the given capacity.

Returns the number of elements in the object.

Returns true if the Object contains no elements.

Returns a reference to the value corresponding to the key.

Get the given value at the given index.

Returns a mutable reference to the value corresponding to the key.

Returns true if the map contains a value for the specified key.

Removes a key from the object, returning the value at the key if the key was previously in the object.

Inserts a key-value pair into the dynamic object, converting it as necessary through the ToValue trait.

Inserts a key-value pair into the dynamic object.

Clears the object, removing all key-value pairs. Keeps the allocated memory for reuse.

Convert into inner.

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a String, &'a Value).

An iterator visiting all keys in arbitrary order. The iterator element type is &'a String.

An iterator visiting all values in arbitrary order. The iterator element type is &'a Value.

An iterator visiting all key-value pairs in arbitrary order, with mutable references to the values. The iterator element type is (&'a String, &'a mut Value).

Convert into a runestick iterator.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

Creates a value from an iterator. Read more

Try to convert to the given type, from the given value.

Hook to install more things into the module.

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 consuming iterator, that is, one that moves each key-value pair out of the object in arbitrary order. The object cannot be used after calling this.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

The generic name of the named thing.

The exact type name

Convert into a value.

Convert into a type hash.

Access diagnostical information on the value type.

The output type from the unsafe coercion.

The raw guard returned. Read more

Convert the given reference using unsafe assumptions to a value. Read more

Coerce the output of an unsafe from value into the final output type. Read more

The output type from the unsafe coercion.

The raw guard returned. Read more

Convert the given reference using unsafe assumptions to a value. Read more

Coerce the output of an unsafe from value into the final output type. Read more

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.