pub struct Value {
    pub raw: Value,
    /* private fields */
}
Expand description

Value represents any value a DM variable can hold, such as numbers, strings, datums, etc.

There’s a lot of lifetime shenanigans going on, the gist of it is to just not keep Values around for longer than your hook’s execution.

Fields

raw: Value

Implementations

Creates a new value from raw tag and data. Use if you know what you are doing.

Equivalent to DM’s global.vars.

Equivalent to DM’s world.

Equivalent to DM’s null.

Gets a turf by ID, without bounds checking. Use turf_by_id if you’re not sure about how to check the bounds.

Gets a turf by ID, with bounds checking.

Gets a turf by coordinates.

Gets a variable by name.

Gets a variable by name and safely casts it to a float.

Gets a variable by name and safely casts it to a string.

Gets a variable by name and safely casts it to a list::List.

Sets a variable by name to a given value.

Check if the current value is a number and casts it.

Check if the current value is a string and casts it.

Check if the current value is a list and casts it.

Calls a method of the value with the given arguments.

Examples:

This example is equivalent to src.explode(3) in DM.

src.call("explode", &[&Value::from(3.0)]);

Gets the type of the Value as a string

Checks whether this Value’s type is equal to typepath.

Creates a Value that references a byond string. Will panic if the given string contains null bytes

Examples:
let my_string = Value::from_string("Testing!");

blah blah lifetime is not verified with this so use at your peril

same as from_raw but does not increment the reference count (assumes we already own this reference)

Creates a WeakValue referencing this datum.

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

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Creates a value from an iterator. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

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.

Should always be Self

The resulting type after obtaining ownership.

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

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

Converts the given value to a String. 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.