Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(slice_patterns)]
- #[derive(Debug,PartialEq)]
- enum Errors {
- Exploded,
- Imploded,
- }
- impl Errors {
- fn to_u32(self) -> u32 {
- self as u32
- }
- }
- fn main() {
- let errors = [Errors::Exploded, Errors::Imploded];
- // let msg = match &errors[..] {
- // [Errors::Exploded, Errors::Imploded] => "It exploded and then imploded",
- // _ => "Not sure what happened",
- // };
- let errors = [Errors::Exploded.to_u32(), Errors::Imploded.to_u32()];
- let msg = match &errors[..] {
- [Errors::Exploded.to_u32(), Errors::Imploded.to_u32()] => "It exploded and then imploded",
- _ => "Not sure what happened",
- };
- println!("{:?}", errors)
- println!("{:?}", msg)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement