Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Barable {
- fn new() -> Self;
- // etc.
- }
- struct Bar;
- impl Barable for Bar {
- fn new() -> Self {
- Bar
- }
- }
- struct Foo<B :Barable> {
- bar: B,
- callback: fn(&B),
- }
- impl<B: Barable> Foo<B> {
- fn new(callback: fn(&B)) -> Self {
- Foo{
- bar: B::new(),
- callback: callback
- }
- }
- }
- fn example_callback(bar: &Bar) {
- }
- fn main() {
- let foo = Foo::new(example_callback);
- }
Add Comment
Please, Sign In to add comment