Guest User

Untitled

a guest
Jan 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // Dummy for what's already in events system
  2. struct Event {}
  3.  
  4. impl Event {
  5. fn event() {
  6. println!("Event")
  7. }
  8.  
  9. fn anti_event() {
  10. println!("Anti-Event")
  11. }
  12. }
  13.  
  14. // Suggested new struct in events infra
  15. struct Gauge {}
  16.  
  17. impl Gauge {
  18. fn new() -> Gauge {
  19. Event::event();
  20. Gauge {}
  21. }
  22. }
  23.  
  24. impl Drop for Gauge {
  25. fn drop(&mut self) {
  26. Event::anti_event();
  27. }
  28. }
  29.  
  30. impl Clone for Gauge {
  31. fn clone(&self) -> Gauge {
  32. Event::event();
  33. Gauge {}
  34. }
  35. }
  36.  
  37. // Test code: a control block and its usage
  38. #[derive(Clone)]
  39. struct CB {
  40. gauge: Gauge,
  41. }
  42.  
  43. impl CB {
  44. fn new() -> CB {
  45. CB { gauge: Gauge::new() }
  46. }
  47. }
  48.  
  49. fn main() {
  50. let cb = CB::new();
  51. let _cb2 = cb.clone();
  52. }
Add Comment
Please, Sign In to add comment