Trait VariantDowncast

Source
pub trait VariantDowncast {
    // Provided methods
    fn as_variant_downcast_ref<T>(&self) -> Option<&T>
       where Self: AsVariantRef<T> { ... }
    fn as_variant_downcast_mut<T>(&mut self) -> Option<&mut T>
       where Self: AsVariantMut<T> { ... }
    fn as_variant_downcast<T>(&self) -> Option<T>
       where T: Clone,
             Self: AsVariant<T> { ... }
    fn into_variant_downcast<T>(self) -> Result<T, Self>
       where Self: IntoVariant<T> { ... }
}
Expand description

Convenience umbrella trait used to do a cheap

  • reference-to-reference
  • mutable-to-mutable reference
  • reference-to-value
  • value-to-value

conversion between an outer enum’s and its inner variant’s type.

Provided Methods§

Source

fn as_variant_downcast_ref<T>(&self) -> Option<&T>
where Self: AsVariantRef<T>,

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

Source

fn as_variant_downcast_mut<T>(&mut self) -> Option<&mut T>
where Self: AsVariantMut<T>,

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

Source

fn as_variant_downcast<T>(&self) -> Option<T>
where T: Clone, Self: AsVariant<T>,

Returns a copy of the inner value if it is of type T, or `None`` if it isn’t.

Source

fn into_variant_downcast<T>(self) -> Result<T, Self>
where Self: IntoVariant<T>,

Converts this type into the variant’s type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§