Guest User

Untitled

a guest
Apr 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum Turn {
  3. Left,
  4. Right,
  5. }
  6.  
  7. impl <'a> From<&'a str> for Turn {
  8. fn from(s: &'a str) -> Turn {
  9. match s {
  10. "L" => Turn::Left,
  11. "R" => Turn::Right,
  12. t => panic!("bad turn description {}", t),
  13. }
  14. }
  15. }
  16.  
  17. fn main() {
  18. println!("{:?}", Turn::from("L"));
  19. }
Add Comment
Please, Sign In to add comment