impl-opaque
Documentation
Declare complex opaque struct using impl block
This crate is no_std.
Usage
trait Trait {
fn run(&self);
}
#[opaque(as pub /* optional struct vis */ , msg: &str /* constructor */ )]
impl Trait for TraitImpl {
fn run(&self) {
#[field]
let ref msg: String = msg.to_string();
println!("{}", msg);
}
}
#[opaque(msg: &str)]
impl Impl {
fn run(&self) {
#[field]
let ref msg: String = msg.to_string();
println!("{}", msg);
}
}
fn main() {
let trait_impl = TraitImpl::new("hello world");
let imp = Impl::new("hello world");
}
Examples
See examples for simple example
License
This crate is licensed under MIT OR Apache-2.0