pub struct MultitraitObject { /* private fields */ }
Expand description

A container to store data with the associated type and trait objects allowing for casting down to trait_impl or the concrete type

use multi_trait_object::prelude::*;
use std::fmt::{Debug, Display};

let mut mto = MultitraitObject::new(String::new());
register_traits!(mto, String, dyn Debug, dyn Display);

let debug = mto.downcast_trait::<dyn Debug>().unwrap();
println!("{:?}", debug);
let display = mto.downcast_trait::<dyn Display>().unwrap();
println!("{}", display);
let string = mto.downcast::<String>().unwrap();
println!("{}", string);

Implementations

Creates a new multitrait object from the given value All trait_impl except Any must be registered on this object in order to access them.

Downcasts the object into a reference of the given trait

Downcasts the object into a mutable reference of the given trait

Downcasts the object to a boxed representation of the given trait

Downcasts the object into a reference of the given type

Downcasts the object into a mutable reference of the given type

Downcasts the object into the given concrete type

Returns if the object stores the given concrete type Use MultitraitObject::implements to check if the object has a given trait

Returns if the object implements a given trait

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.