| Crates.io | box-dyn |
| lib.rs | box-dyn |
| version | 0.0.8 |
| created_at | 2024-05-24 18:12:35.234166+00 |
| updated_at | 2024-05-24 20:44:45.889392+00 |
| description | Macro to derive the implementation of Trait for Box |
| homepage | https://github.com/romnn/box-dyn |
| repository | https://github.com/romnn/box-dyn |
| max_upload_size | |
| id | 1251401 |
| size | 13,966 |
A simple macro, here is how to use it:
#[box_dyn::box_dyn]
trait MyTrait {
fn method_a(&self, param: usize) -> String;
fn method_b(&mut self);
}
This will automatically implement MyTrait for Box<T: MyTrait>:
impl<T> MyTrait for Box<T> where T: MyTrait {
fn method_a(&self, param: usize) -> String {
MyTrait::method_a(self.as_ref(), param)
}
fn method_b(&mut self) {
MyTrait::method_b(self.as_mut())
}
}