Skip to main content

AnyVarValue

Trait AnyVarValue 

Source
pub trait AnyVarValue:
    Debug
    + Any
    + Send
    + Sync {
    // Required methods
    fn clone_boxed(&self) -> BoxAnyVarValue;
    fn eq_any(&self, other: &dyn AnyVarValue) -> bool;
    fn type_name(&self) -> &'static str;
    fn try_swap(&mut self, other: &mut dyn AnyVarValue) -> bool;
}
Expand description

Represents any variable value.

§Trait Alias

This trait is used like a type alias for traits and is already implemented for all types it can apply to.

See VarValue<T> for more details.

Required Methods§

Source

fn clone_boxed(&self) -> BoxAnyVarValue

Clone the value.

Source

fn eq_any(&self, other: &dyn AnyVarValue) -> bool

Gets if self and other are equal.

Source

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

Value type name.

Note that this string is not stable and should be used for debug only.

Source

fn try_swap(&mut self, other: &mut dyn AnyVarValue) -> bool

Swap value with other if both are of the same type.

Implementations§

Source§

impl dyn AnyVarValue

Source

pub fn downcast_ref<T: VarValue>(&self) -> Option<&T>

Returns some reference to the inner value if it is of type T, or None if it isn’t.

Source

pub fn downcast_mut<T: VarValue>(&mut self) -> Option<&mut T>

Returns some mutable reference to the inner value if it is of type T, or None if it isn’t.

Source

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

Returns true if the inner type is the same as T.

Trait Implementations§

Source§

impl PartialEq for dyn AnyVarValue

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> AnyVarValue for T
where T: Debug + PartialEq + Clone + Any + Send + Sync,