@@ -19,15 +19,9 @@ pub(super) struct DebuggerCommands {
19
19
}
20
20
21
21
impl DebuggerCommands {
22
- pub fn parse_from (
23
- file : & Path ,
24
- config : & Config ,
25
- debugger_prefixes : & [ & str ] ,
26
- ) -> Result < Self , String > {
27
- let directives = debugger_prefixes
28
- . iter ( )
29
- . map ( |prefix| ( format ! ( "{prefix}-command" ) , format ! ( "{prefix}-check" ) ) )
30
- . collect :: < Vec < _ > > ( ) ;
22
+ pub fn parse_from ( file : & Path , config : & Config , debugger_prefix : & str ) -> Result < Self , String > {
23
+ let command_directive = format ! ( "{debugger_prefix}-command" ) ;
24
+ let check_directive = format ! ( "{debugger_prefix}-check" ) ;
31
25
32
26
let mut breakpoint_lines = vec ! [ ] ;
33
27
let mut commands = vec ! [ ] ;
@@ -48,14 +42,11 @@ impl DebuggerCommands {
48
42
continue ;
49
43
} ;
50
44
51
- for & ( ref command_directive, ref check_directive) in & directives {
52
- config
53
- . parse_name_value_directive ( & line, command_directive)
54
- . map ( |cmd| commands. push ( cmd) ) ;
55
-
56
- config
57
- . parse_name_value_directive ( & line, check_directive)
58
- . map ( |cmd| check_lines. push ( ( line_no, cmd) ) ) ;
45
+ if let Some ( command) = config. parse_name_value_directive ( & line, & command_directive) {
46
+ commands. push ( command) ;
47
+ }
48
+ if let Some ( pattern) = config. parse_name_value_directive ( & line, & check_directive) {
49
+ check_lines. push ( ( line_no, pattern) ) ;
59
50
}
60
51
}
61
52
0 commit comments