Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum Hello {
  3. Bonjour,
  4. Nihao
  5. }
  6.  
  7. trait SayHello<T> {
  8. fn hello(action: &str) -> Result<T, &'static str> ;
  9. }
  10.  
  11. impl SayHello<Hello> for Hello {
  12. fn hello(action: &str) -> Result<Hello, &'static str> {
  13. match action {
  14. "bonjour" => Ok(Hello::Bonjour),
  15. "nihao" => Ok(Hello::Nihao),
  16. _ => Err("lol")
  17. }
  18. }
  19. }
  20.  
  21.  
  22. fn main() {
  23. println!("Hello, world!");
  24. let hello = Hello::hello("nihao");
  25. println!("ntm {:?}", hello)
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement