SHARE
TWEET

Untitled

a guest Oct 21st, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[derive(Debug)]
  2. pub struct Counter<'a> {
  3.     pub name: &'a str,
  4.     pub tally: u64,
  5. }
  6.  
  7. impl<'a> Counter<'a> {
  8.     pub fn new(name: &str) -> Counter {
  9.         Counter {
  10.             name,
  11.             tally: 0,
  12.         }
  13.     }
  14.     pub fn max(x: Counter<'a>, y: Counter<'a>) -> Counter<'a> {
  15.         if x.tally > y.tally {
  16.             x
  17.         } else {
  18.             y
  19.         }
  20.     }
  21.  
  22.     pub fn increase(&mut self) {
  23.         self.tally += 1;
  24.     }
  25. }
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
 
Top