[][src]Trait cursive::view::AnyView

pub trait AnyView {
    fn as_any(&self) -> &(dyn Any + 'static);
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
fn as_boxed_any(self: Box<Self>) -> Box<dyn Any + 'static>; }

A view that can be downcasted to its concrete type.

This trait is automatically implemented for any T: View.

Required methods

fn as_any(&self) -> &(dyn Any + 'static)

Downcast self to a Any.

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Downcast self to a mutable Any.

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

Returns a boxed any from a boxed self.

Can be used before Box::downcast().

Examples

let boxed: Box<View> = Box::new(TextView::new("text"));
let text: Box<TextView> = boxed.as_boxed_any().downcast().unwrap();
Loading content...

Implementations

impl dyn AnyView + 'static[src]

pub fn downcast_ref<T>(&self) -> Option<&T> where
    T: Any
[src]

Attempts to downcast self to a concrete type.

pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
    T: Any
[src]

Attempts to downcast self to a concrete type.

pub fn downcast<T>(
    self: Box<dyn AnyView + 'static>
) -> Result<Box<T>, Box<dyn AnyView + 'static>> where
    T: Any
[src]

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

pub fn is<T>(&mut self) -> bool where
    T: Any
[src]

Checks if this view is of type T.

Implementors

impl<T> AnyView for T where
    T: View
[src]

fn as_any(&self) -> &(dyn Any + 'static)[src]

Downcast self to a Any.

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]

Downcast self to a mutable Any.

Loading content...