Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. trait Barable {
  2. fn new() -> Self;
  3. // etc.
  4. }
  5.  
  6. struct Bar;
  7.  
  8. impl Barable for Bar {
  9. fn new() -> Self {
  10. Bar
  11. }
  12. }
  13.  
  14. struct Foo<B :Barable> {
  15. bar: B,
  16. callback: fn(&B),
  17. }
  18.  
  19. impl<B: Barable> Foo<B> {
  20. fn new(callback: fn(&B)) -> Self {
  21. Foo{
  22. bar: B::new(),
  23. callback: callback
  24. }
  25. }
  26. }
  27.  
  28. fn example_callback(bar: &Bar) {
  29. }
  30.  
  31. fn main() {
  32. let foo = Foo::new(example_callback);
  33. }
Add Comment
Please, Sign In to add comment