@@ -11,6 +11,7 @@ use fast_automaton::FastAutomaton;
11
11
use nohash_hasher:: NoHashHasher ;
12
12
use regex:: RegularExpression ;
13
13
use regex_charclass:: { char:: Char , irange:: RangeSet } ;
14
+ #[ cfg( feature = "serde" ) ]
14
15
use serde:: { Deserialize , Serialize } ;
15
16
16
17
pub mod cardinality;
@@ -27,12 +28,13 @@ type Range = RangeSet<Char>;
27
28
/// Represents a term that can be either a regular expression or a finite automaton. This term can be manipulated with a wide range of operations.
28
29
///
29
30
/// To put constraint and limitation on the execution of operations please refer to [`execution_profile::ExecutionProfile`].
30
- #[ derive( Clone , PartialEq , Eq , Debug , Serialize , Deserialize ) ]
31
- #[ serde( tag = "type" , content = "value" ) ]
31
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
32
+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
33
+ #[ cfg_attr( feature = "serde" , serde( tag = "type" , content = "value" ) ) ]
32
34
pub enum Term {
33
- #[ serde( rename = "regex" ) ]
35
+ #[ cfg_attr ( feature = " serde" , serde ( rename = "regex" ) ) ]
34
36
RegularExpression ( RegularExpression ) ,
35
- #[ serde( rename = "fair" ) ]
37
+ #[ cfg_attr ( feature = " serde" , serde ( rename = "fair" ) ) ]
36
38
Automaton ( FastAutomaton ) ,
37
39
}
38
40
@@ -319,8 +321,9 @@ impl Term {
319
321
}
320
322
321
323
/// Represents details about a [Term].
322
- #[ derive( Clone , PartialEq , Eq , Debug , Serialize , Deserialize ) ]
323
- #[ serde( tag = "type" , rename = "details" ) ]
324
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
325
+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
326
+ #[ cfg_attr( feature = "serde" , serde( tag = "type" , rename = "details" ) ) ]
324
327
pub struct Details {
325
328
cardinality : Option < Cardinality < u32 > > ,
326
329
length : ( Option < u32 > , Option < u32 > ) ,
0 commit comments