@@ -11,6 +11,7 @@ use fast_automaton::FastAutomaton;
1111use nohash_hasher:: NoHashHasher ;
1212use regex:: RegularExpression ;
1313use regex_charclass:: { char:: Char , irange:: RangeSet } ;
14+ #[ cfg( feature = "serde" ) ]
1415use serde:: { Deserialize , Serialize } ;
1516
1617pub mod cardinality;
@@ -27,12 +28,13 @@ type Range = RangeSet<Char>;
2728/// 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.
2829///
2930/// 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" ) ) ]
3234pub enum Term {
33- #[ serde( rename = "regex" ) ]
35+ #[ cfg_attr ( feature = " serde" , serde ( rename = "regex" ) ) ]
3436 RegularExpression ( RegularExpression ) ,
35- #[ serde( rename = "fair" ) ]
37+ #[ cfg_attr ( feature = " serde" , serde ( rename = "fair" ) ) ]
3638 Automaton ( FastAutomaton ) ,
3739}
3840
@@ -319,8 +321,9 @@ impl Term {
319321}
320322
321323/// 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" ) ) ]
324327pub struct Details {
325328 cardinality : Option < Cardinality < u32 > > ,
326329 length : ( Option < u32 > , Option < u32 > ) ,
0 commit comments