@@ -367,23 +367,38 @@ impl<T: Iterator<Item = char>> Parser<T> {
367367 }
368368
369369 fn parser_process_directives ( & mut self ) -> Result < ( ) , ScanError > {
370+ enum DirectiveAction {
371+ None ,
372+ Tag { handle : String , prefix : String } ,
373+ }
374+
370375 loop {
371- match self . peek_token ( ) ?. 1 {
376+ // Without NLL, split the peek and the action
377+ let action = match self . peek_token ( ) ?. 1 {
372378 TokenType :: VersionDirective ( _, _) => {
373379 // XXX parsing with warning according to spec
374380 //if major != 1 || minor > 2 {
375381 // return Err(ScanError::new(tok.0,
376382 // "found incompatible YAML document"));
377383 //}
384+ DirectiveAction :: None
378385 }
379386 TokenType :: TagDirective ( ref handle, ref prefix) => {
380- let handle = String :: from ( handle) ;
381- let mut prefix = String :: from ( prefix) ;
387+ let handle = String :: clone ( handle) ;
388+ let mut prefix = String :: clone ( prefix) ;
382389 prefix. pop ( ) ;
383- self . tag_directives . insert ( handle, prefix) ;
390+ DirectiveAction :: Tag { handle, prefix }
384391 }
385392 _ => break ,
393+ } ;
394+
395+ match action {
396+ DirectiveAction :: Tag { handle, prefix } => {
397+ self . tag_directives . insert ( handle, prefix) ;
398+ }
399+ _ => ( ) ,
386400 }
401+
387402 self . skip ( ) ;
388403 }
389404 Ok ( ( ) )
0 commit comments