Struct incrust::types::btype::BType
[−]
[src]
pub struct BType(pub Box<Type>);
Methods from Deref<Target=Box<Type>>
fn downcast<T>(self) -> Result<Box<T>, Box<Any + 'static>> where T: Any
1.0.0
Attempt to downcast the box to a concrete type.
Examples
use std::any::Any; fn print_if_string(value: Box<Any>) { if let Ok(string) = value.downcast::<String>() { println!("String ({}): {}", string.len(), string); } } fn main() { let my_string = "Hello World".to_string(); print_if_string(Box::new(my_string)); print_if_string(Box::new(0i8)); }
fn downcast<T>(self) -> Result<Box<T>, Box<Any + 'static + Send>> where T: Any
1.0.0
Attempt to downcast the box to a concrete type.
Examples
use std::any::Any; fn print_if_string(value: Box<Any + Send>) { if let Ok(string) = value.downcast::<String>() { println!("String ({}): {}", string.len(), string); } } fn main() { let my_string = "Hello World".to_string(); print_if_string(Box::new(my_string)); print_if_string(Box::new(0i8)); }
Trait Implementations
impl Debug for BType
[src]
impl<T> From<T> for BType where T: Type + 'static
[src]
fn from(b: T) -> Self
Performs the conversion.
impl Deref for BType
[src]
type Target = Box<Type>
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value
impl Clone for BType
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more