Created
October 13, 2018 00:10
-
-
Save JuanCaicedo/d9e3e9908a3591dbdae8772767a4dd69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Action { | |
_type: String, | |
amount: u32 | |
} | |
fn update_counter(state:u32, action: Action) { | |
let Action {_type, amount} = action; | |
return match _type.as_ref() { | |
"INCREMENT" => state + amount, | |
"DECREMENT" => state - amount, | |
"RESET" => 0, | |
_ => state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment