File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ pub enum Attribute {
3232
3333#[ derive( Debug , PartialEq ) ]
3434pub enum Pattern {
35+ Empty ,
3536 Characters ( String ) ,
3637 Boundary ,
3738 Any ,
@@ -218,9 +219,13 @@ impl<'a> PatternParser<'a> {
218219
219220 pub fn pattern ( & mut self ) -> Result < Patterns , ParseError > {
220221 let mut patterns: Patterns = Vec :: new ( ) ;
221- while self . chars . peek ( ) . is_some ( ) {
222- patterns. push ( self . pattern_with_quantifier ( ) ?) ;
223- }
222+ if self . chars . next_if ( |& c| c == '-' ) . is_some ( ) {
223+ patterns. push ( Pattern :: Empty ) ;
224+ } else {
225+ while self . chars . peek ( ) . is_some ( ) {
226+ patterns. push ( self . pattern_with_quantifier ( ) ?) ;
227+ }
228+ }
224229 Ok ( patterns)
225230 }
226231}
@@ -333,5 +338,9 @@ mod tests {
333338 PatternParser :: new( "a**" ) . pattern( ) ,
334339 Err ( ParseError :: MissingPatternBeforeQuantifier )
335340 ) ;
341+ assert_eq ! (
342+ PatternParser :: new( "-" ) . pattern( ) ,
343+ Ok ( vec![ Pattern :: Empty ] )
344+ ) ;
336345 }
337346}
You can’t perform that action at this time.
0 commit comments