Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- pub struct Counter<'a> {
- pub name: &'a str,
- pub tally: u64,
- }
- impl<'a> Counter<'a> {
- pub fn new(name: &str) -> Counter {
- Counter {
- name,
- tally: 0,
- }
- }
- pub fn max(x: Counter<'a>, y: Counter<'a>) -> Counter<'a> {
- if x.tally > y.tally {
- x
- } else {
- y
- }
- }
- pub fn increase(&mut self) {
- self.tally += 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement