Guest User

Untitled

a guest
Dec 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum Foo {
  3. Bar,
  4. Baz
  5. }
  6.  
  7. impl From<char> for Foo {
  8. fn from(c: char) -> Foo {
  9. match c {
  10. 'c' => Foo::Bar,
  11. _ => Foo::Baz
  12. }
  13. }
  14. }
  15.  
  16. fn main() {
  17. let f = 'c';
  18. let g = 'd';
  19. let fe:Foo = f.into();
  20. let ge:Foo = g.into();
  21. println!("{:?}, {:?}", fe, ge)
  22.  
  23. }
Add Comment
Please, Sign In to add comment