Trait sum_type::SumType [−][src]
pub trait SumType { fn variant(&self) -> &'static str; fn variants(&self) -> &'static [&'static str]; fn downcast_ref<T: Any>(&self) -> Option<&T>; fn downcast_mut<T: Any>(&mut self) -> Option<&mut T>; fn variant_is<T: Any>(&self) -> bool; }
Various methods for introspection and dynamic typing.
Note
This trait is automatically implemented for all types generated by the
sum_type!()
macro. You should never need to implement it manually.
Required Methods
fn variant(&self) -> &'static str
The name of the current variant.
fn variants(&self) -> &'static [&'static str]
A list of all possible variants.
fn downcast_ref<T: Any>(&self) -> Option<&T>
Try to get a reference to the inner field if it is a T
.
fn downcast_mut<T: Any>(&mut self) -> Option<&mut T>
Return a mutable reference to the inner field if it is a T
.
fn variant_is<T: Any>(&self) -> bool
Is the underlying variant an instance of T
?
Implementors
impl SumType for MySumType