SHARE
TWEET

Untitled

a guest Sep 15th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern crate arm_and_handler;
  2.  
  3. use arm_and_handler::arm;
  4. use arm_and_handler::arm_and_handler;
  5. use arm_and_handler::handle;
  6.  
  7. struct T {
  8.   i: usize,
  9. }
  10.  
  11. #[arm_and_handler]
  12. impl T {
  13.   pub fn new(i: usize) -> Self {
  14.     T { i }
  15.   }
  16.  
  17.   #[arm(1)]
  18.   pub fn arm1(&self, s: String) {
  19.     println!("arm1: {}", s);
  20.   }
  21.  
  22.   #[arm(2)]
  23.   pub fn arm2(&self, s: String) {
  24.     println!("arm2: {}", s);
  25.   }
  26.  
  27.   #[arm(_)]
  28.   pub fn arm_(&self, s: String) {
  29.     println!("Oops: {}", s);
  30.   }
  31.  
  32.   #[handle(i, param)]
  33.   pub fn handler(&self) {
  34.     let i = self.i;
  35.     let param = "xxx".to_string();
  36.   }
  37. }
  38.  
  39. fn main() {
  40.   T::new(1).handler();
  41.   T::new(2).handler();
  42.   T::new(3).handler();
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top