1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Syntax { PROTO2, PROTO3, } impl Syntax { pub fn parse(s: &str) -> Self { match s { "" | "proto2" => Syntax::PROTO2, "proto3" => Syntax::PROTO3, _ => panic!("unsupported syntax value: {:?}", s), } } }