@@ -33,21 +33,21 @@ impl fmt::Display for ParseError {
3333
3434impl ShortcutCommand {
3535 pub fn parse < ' a > ( input : & mut Tokenizer < ' a > ) -> Result < Option < Self > , Error < ' a > > {
36- let mut shortcuts = HashMap :: new ( ) ;
37- shortcuts. insert ( "ready" , ShortcutCommand :: Ready ) ;
38- shortcuts. insert ( "review" , ShortcutCommand :: Ready ) ;
39- shortcuts. insert ( "reviewer" , ShortcutCommand :: Ready ) ;
40- shortcuts. insert ( "author" , ShortcutCommand :: Author ) ;
41- shortcuts. insert ( "blocked" , ShortcutCommand :: Blocked ) ;
36+ let shortcuts = HashMap :: from ( [
37+ ( "ready" , ShortcutCommand :: Ready ) ,
38+ ( "review" , ShortcutCommand :: Ready ) ,
39+ ( "reviewer" , ShortcutCommand :: Ready ) ,
40+ ( "author" , ShortcutCommand :: Author ) ,
41+ ( "blocked" , ShortcutCommand :: Blocked ) ,
42+ ] ) ;
4243
4344 let mut toks = input. clone ( ) ;
4445 if let Some ( Token :: Word ( word) ) = toks. peek_token ( ) ? {
45- if ! shortcuts. contains_key ( word) {
46+ let Some ( command ) = shortcuts. get ( word) else {
4647 return Ok ( None ) ;
47- }
48+ } ;
4849 toks. next_token ( ) ?;
4950 * input = toks;
50- let command = shortcuts. get ( word) . unwrap ( ) ;
5151 return Ok ( Some ( * command) ) ;
5252 }
5353 Ok ( None )
@@ -57,7 +57,7 @@ impl ShortcutCommand {
5757#[ cfg( test) ]
5858fn parse ( input : & str ) -> Result < Option < ShortcutCommand > , Error < ' _ > > {
5959 let mut toks = Tokenizer :: new ( input) ;
60- Ok ( ShortcutCommand :: parse ( & mut toks) ? )
60+ ShortcutCommand :: parse ( & mut toks)
6161}
6262
6363#[ test]
0 commit comments