Guest User

Untitled

a guest
Jul 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. trait EventReceiverObject {
  2. fn event(&self, e: i32);
  3. }
  4.  
  5. struct MyObject {}
  6.  
  7. impl EventReceiverObject for MyObject {
  8. fn event(&self, e: i32) {
  9. println!("Handling event {}", e);
  10. }
  11. }
  12.  
  13. fn main() {
  14. use std::rc::Rc;
  15. let a = Rc::new(MyObject {});
  16. let b: Rc<dyn EventReceiverObject> = a;
  17.  
  18. println!("Hello, world!");
  19. }
Add Comment
Please, Sign In to add comment