@@ -24,19 +24,6 @@ impl ConfigurationSection {
2424 fn get_section < I : Iterator < Item = String > > (
2525 file : & mut Enumerate < I > ,
2626 ) -> Option < ConfigurationSection > {
27- lazy_static ! {
28- static ref CONFIG_NAME_REGEX : regex:: Regex =
29- regex:: Regex :: new( r"^## `([^`]+)`" ) . expect( "failed creating configuration pattern" ) ;
30- // Configuration values, which will be passed to `from_str`:
31- //
32- // - must be prefixed with `####`
33- // - must be wrapped in backticks
34- // - may by wrapped in double quotes (which will be stripped)
35- static ref CONFIG_VALUE_REGEX : regex:: Regex =
36- regex:: Regex :: new( r#"^#### `"?([^`]+?)"?`"# )
37- . expect( "failed creating configuration value pattern" ) ;
38- }
39-
4027 loop {
4128 match file. next ( ) {
4229 Some ( ( i, line) ) => {
@@ -53,9 +40,14 @@ impl ConfigurationSection {
5340 let start_line = ( i + 2 ) as u32 ;
5441
5542 return Some ( ConfigurationSection :: CodeBlock ( ( block, start_line) ) ) ;
56- } else if let Some ( c) = CONFIG_NAME_REGEX . captures ( & line) {
43+ } else if let Some ( c) = static_regex ! ( r"^## `([^`]+)`" ) . captures ( & line) {
5744 return Some ( ConfigurationSection :: ConfigName ( String :: from ( & c[ 1 ] ) ) ) ;
58- } else if let Some ( c) = CONFIG_VALUE_REGEX . captures ( & line) {
45+ } else if let Some ( c) = static_regex ! ( r#"^#### `"?([^`]+?)"?`"# ) . captures ( & line) {
46+ // Configuration values, which will be passed to `from_str`
47+ //
48+ // - must be prefixed with `####`
49+ // - must be wrapped in backticks
50+ // - may by wrapped in double quotes (which will be stripped)
5951 return Some ( ConfigurationSection :: ConfigValue ( String :: from ( & c[ 1 ] ) ) ) ;
6052 }
6153 }
0 commit comments