Attribute Macro ambassador::delegatable_trait_remote
source ยท #[delegatable_trait_remote]
Expand description
Make an existing trait that lives outside you crate available for delegation.
This can be done by copy-pasting the existing traits signature into your code under this attribute
use ambassador::{Delegate, delegatable_trait_remote};
use std::fmt::Display;
#[delegatable_trait_remote]
trait Display {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error>;
}
struct Cat;
impl Display for Cat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error>{
f.write_str("Cat")
}
}
#[derive(Delegate)]
#[delegate(Display)] // <-------- Delegate implementation of Display to struct field
pub struct WrappedCat(Cat);