@@ -46,6 +46,7 @@ use std::str::FromStr;
4646struct Filter {
4747 domain : String ,
4848 regex : Regex ,
49+ inverted : bool ,
4950}
5051
5152#[ derive( Debug , Display ) ]
@@ -73,6 +74,11 @@ impl FromStr for Filter {
7374 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
7475 let ( domain, regex) = s. split_once ( '=' ) . ok_or ( FilterError :: NoFilter ) ?;
7576
77+ let ( regex, inverted) = regex
78+ . strip_prefix ( '-' )
79+ . map ( |regex| ( regex, true ) )
80+ . unwrap_or ( ( regex, false ) ) ;
81+
7682 let regex = regex. strip_prefix ( '/' ) . ok_or ( FilterError :: NoOpeningSlash ) ?;
7783 let regex = regex. strip_suffix ( '/' ) . ok_or ( FilterError :: NoClosingSlash ) ?;
7884
@@ -83,6 +89,7 @@ impl FromStr for Filter {
8389 Ok ( Filter {
8490 domain : domain. to_owned ( ) ,
8591 regex,
92+ inverted,
8693 } )
8794 }
8895}
@@ -585,13 +592,15 @@ fn main() -> eyre::Result<()> {
585592 . iter ( )
586593 . fold ( HashMap :: new ( ) , |mut map, filter| {
587594 map. entry ( & filter. domain )
588- . and_modify ( |v : & mut Vec < _ > | v. push ( filter. regex . clone ( ) ) )
589- . or_insert_with ( || vec ! [ filter. regex. clone( ) ] ) ;
595+ . and_modify ( |v : & mut Vec < _ > | v. push ( ( filter. regex . clone ( ) , filter . inverted ) ) )
596+ . or_insert_with ( || vec ! [ ( filter. regex. clone( ) , filter . inverted ) ] ) ;
590597 map
591598 } ) ;
592599 for ( domain, filters) in attribute_filters {
593600 driver = driver. with_marker_attributes_filter ( domain, move |attr| {
594- filters. iter ( ) . all ( |regex| regex. is_match ( attr) )
601+ filters
602+ . iter ( )
603+ . all ( |( regex, inverted) | regex. is_match ( attr) ^ inverted)
595604 } )
596605 }
597606
0 commit comments