datex_core::datex_values

Trait Value

Source
pub trait Value: Any {
    // Required methods
    fn to_string(&self) -> String;
    fn cast(&self, dx_type: Type) -> ValueResult;
    fn binary_operation(
        &self,
        code: BinaryCode,
        other: Box<dyn Value>,
    ) -> ValueResult;
}

Required Methods§

Source

fn to_string(&self) -> String

Source

fn cast(&self, dx_type: Type) -> ValueResult

Source

fn binary_operation( &self, code: BinaryCode, other: Box<dyn Value>, ) -> ValueResult

Implementations§

Source§

impl dyn Value

Source

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

Returns true if the boxed type is the same as T

Source

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

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

Source

pub unsafe fn downcast_ref_unchecked<T: Value>(&self) -> &T

Returns a reference to the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

Source

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

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

Source

pub unsafe fn downcast_mut_unchecked<T: Value>(&mut self) -> &mut T

Returns a mutable reference to the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

Source§

impl dyn Value

Source

pub fn downcast<T: Value>(self: Box<Self>) -> Result<Box<T>, Box<Self>>

Returns the boxed value if it is of type T, or Err(Self) if it isn’t.

Source

pub unsafe fn downcast_unchecked<T: Value>(self: Box<Self>) -> Box<T>

Returns the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

Trait Implementations§

Source§

impl Display for dyn Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§