@@ -90,6 +90,27 @@ pub struct DocPattern {
9090 pub argument_seperator : String ,
9191}
9292
93+ #[ derive( Deserialize , Debug , Clone ) ]
94+ #[ serde( untagged) ]
95+ pub enum ClassMatch {
96+ One ( String ) ,
97+ Many ( Vec < String > ) ,
98+ }
99+
100+ impl Default for ClassMatch {
101+ fn default ( ) -> Self {
102+ Self :: One ( "" . to_string ( ) )
103+ }
104+ }
105+ impl ClassMatch {
106+ fn matches ( & self , class : & str ) -> bool {
107+ match self {
108+ Self :: One ( p) => class. starts_with ( p) ,
109+ Self :: Many ( pp) => pp. iter ( ) . any ( |p| class. starts_with ( p) ) ,
110+ }
111+ }
112+ }
113+
93114#[ derive( Debug , Clone , Deserialize , Default ) ]
94115pub struct Rule {
95116 /// What java class(es) to match against. This takes the form of a simple prefix to a JNI path with no wildcards.
@@ -99,9 +120,8 @@ pub struct Rule {
99120 /// | * | jni_prefix = ""
100121 /// | java.lang.* | jni_prefix = "java/lang/"
101122 /// | name.spaces.OuterClass.* | jni_prefix = "name/spaces/OuterClass$"
102- #[ serde( default ) ]
103123 #[ serde( rename = "match" ) ]
104- pub matches : Vec < String > ,
124+ pub matches : ClassMatch ,
105125
106126 #[ serde( default ) ]
107127 pub include : Option < bool > ,
@@ -163,7 +183,8 @@ impl Config {
163183
164184 if config. rules . is_empty ( ) {
165185 config. rules . push ( Rule {
166- matches : vec ! [ "" . to_string( ) ] ,
186+ matches : ClassMatch :: default ( ) ,
187+ include : Some ( true ) ,
167188 ..Default :: default ( )
168189 } )
169190 }
@@ -217,7 +238,7 @@ impl Config {
217238 } ;
218239
219240 for r in & self . rules {
220- if r. matches . iter ( ) . any ( |p| class. starts_with ( p ) ) {
241+ if r. matches . matches ( class) {
221242 if let Some ( include) = r. include {
222243 res. include = include;
223244 }
0 commit comments