Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dummy for what's already in events system
- struct Event {}
- impl Event {
- fn event() {
- println!("Event")
- }
- fn anti_event() {
- println!("Anti-Event")
- }
- }
- // Suggested new struct in events infra
- struct Gauge {}
- impl Gauge {
- fn new() -> Gauge {
- Event::event();
- Gauge {}
- }
- }
- impl Drop for Gauge {
- fn drop(&mut self) {
- Event::anti_event();
- }
- }
- impl Clone for Gauge {
- fn clone(&self) -> Gauge {
- Event::event();
- Gauge {}
- }
- }
- // Test code: a control block and its usage
- #[derive(Clone)]
- struct CB {
- gauge: Gauge,
- }
- impl CB {
- fn new() -> CB {
- CB { gauge: Gauge::new() }
- }
- }
- fn main() {
- let cb = CB::new();
- let _cb2 = cb.clone();
- }
Add Comment
Please, Sign In to add comment