Trait rhai::Variant

source ·
pub trait Variant: Any + Sealed {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn as_boxed_any(self: Box<Self>) -> Box<dyn Any>;
    fn type_name(&self) -> &'static str;
    fn clone_object(&self) -> Box<dyn Variant>;
}
Expand description

(internals) Trait to represent any type. Exported under the internals feature only.

This trait is sealed and cannot be implemented.

Currently, Variant 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.

Required Methods§

source

fn as_any(&self) -> &dyn Any

Convert this Variant trait object to &dyn Any.

source

fn as_any_mut(&mut self) -> &mut dyn Any

Convert this Variant trait object to &mut dyn Any.

source

fn as_boxed_any(self: Box<Self>) -> Box<dyn Any>

Convert this Variant trait object to Box<dyn Any>.

source

fn type_name(&self) -> &'static str

Get the name of this type.

source

fn clone_object(&self) -> Box<dyn Variant>

Clone this Variant trait object.

Implementations§

source§

impl dyn Variant

source

pub fn is<T: Any>(&self) -> bool

Is this Variant a specific type?

Implementors§

source§

impl<T: Any + Clone + SendSync> Variant for T