Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. use rocket::State;
  2.  
  3. pub fn main() {
  4. rocket::ignite()
  5. .manage(ServerState::new())
  6. .mount("/", routes![clear]).launch();
  7. }
  8.  
  9. struct ServerState {
  10. pub board: usize
  11. }
  12.  
  13. impl ServerState {
  14.  
  15. pub fn new() -> ServerState {
  16. ServerState {
  17. board: 0
  18. }
  19. }
  20.  
  21. pub fn clear(&mut self) {
  22. self.board = 0;
  23. }
  24.  
  25. }
  26.  
  27. #[post("/clear")]
  28. fn clear(mut state: State<ServerState>) -> () {
  29. state.clear();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement