Trait cursive_core::view::AnyView

source ·
pub trait AnyView {
    // 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>;
}
Expand description

A view that can be downcasted to its concrete type.

This trait is automatically implemented for any T: View.

Required Methods§

source

fn as_any(&self) -> &dyn Any

Downcast self to a Any.

source

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

Downcast self to a mutable Any.

source

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

Returns a boxed any from a boxed self.

Can be used before Box::downcast().

§Examples
let boxed: Box<dyn View> = Box::new(TextView::new("text"));
let text: Box<TextView> = boxed.as_boxed_any().downcast().unwrap();

Implementations§

source§

impl dyn AnyView

source

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

Attempts to downcast self to a concrete type.

source

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

Attempts to downcast self to a concrete type.

source

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

Attempts to downcast Box<Self> to a concrete type.

source

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

Checks if this view is of type T.

Implementors§

source§

impl<T: View> AnyView for T