Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.29 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum Foo {
  3.     A,
  4.     B,
  5.     C
  6. }
  7.  
  8. impl Foo {
  9.     fn testing(&self) -> u8 {
  10.         match self {
  11.             Foo::A => 0,
  12.             Foo::B => 1,
  13.             Foo::C => 2,
  14.         }
  15.     }
  16. }
  17.  
  18. fn main() {
  19.     let bar = Foo::A;
  20.  
  21.     println!("{:?}", bar.testing());
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement