Advertisement
Guest User

Untitled

a guest
May 26th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. use serde::{Deserialize, Serialize};
  2. use std::string::ToString;
  3.  
  4. #[derive(Debug, Serialize, Deserialize)]
  5. #[serde(rename_all = "kebab-case")]
  6. enum Action {
  7. OptIn,
  8. OptOut,
  9. }
  10.  
  11. impl ToString for Action {
  12. fn to_string(&self) -> String {
  13. serde_json::to_string(&self).unwrap()
  14. }
  15. }
  16.  
  17. fn main() {
  18. let opt_in = Action::OptIn;
  19. let out = Action::OptOut;
  20.  
  21. println!("Hello, world!, {}, {}", opt_in.to_string(), out.to_string());
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement