[go: up one dir, main page]

[][src]Type Definition rhai::Dynamic

type Dynamic = Box<Variant>;

A boxed dynamic type containing any value.

Currently, Dynamic is not Send nor Sync, so it can practically be any type. Turn on the sync feature to restrict it to only types that implement Send + Sync.

Trait Implementations

impl AnyExt for Dynamic[src]

fn try_cast<T: Any + Clone>(self) -> Result<T, Self>[src]

Get a copy of the Dynamic value as a specific type.

Example

use rhai::{Dynamic, Any, AnyExt};

let x: Dynamic = 42_u32.into_dynamic();

assert_eq!(x.try_cast::<u32>().unwrap(), 42);

fn cast<T: Any + Clone>(self) -> T[src]

Get a copy of the Dynamic value as a specific type.

Panics

Panics if the cast fails (e.g. the type of the actual value is not the same as the specified type).

Example

use rhai::{Dynamic, Any, AnyExt};

let x: Dynamic = 42_u32.into_dynamic();

assert_eq!(x.cast::<u32>(), 42);

impl Clone for Dynamic[src]