@@ -8,35 +8,28 @@ use crate::core::ResolvedParamTypes;
88/// The signature of a FUNCTION or SUB.
99/// Consists of the resolved parameter types and, in case of a FUNCTION, the return type.
1010#[ derive( PartialEq ) ]
11- pub struct Signature {
12- /// The return type of a FUNCTION, or None if this is the signature of a SUB.
13- q : Option < TypeQualifier > ,
11+ pub enum Signature {
12+ /// The signature of a FUNCTION consists of the resolved parameter types
13+ /// and the return type.
14+ Function ( ResolvedParamTypes , TypeQualifier ) ,
1415
15- /// The resolved parameter types.
16- param_types : ResolvedParamTypes ,
16+ /// The signature of a SUB consists of the resolved parameter types.
17+ Sub ( ResolvedParamTypes ) ,
1718}
1819
1920impl Signature {
20- pub fn new_sub ( param_types : ResolvedParamTypes ) -> Self {
21- Self {
22- q : None ,
23- param_types,
24- }
25- }
26-
27- pub fn new_function ( q : TypeQualifier , param_types : ResolvedParamTypes ) -> Self {
28- Self {
29- q : Some ( q) ,
30- param_types,
31- }
32- }
33-
3421 pub fn qualifier ( & self ) -> Option < TypeQualifier > {
35- self . q . as_ref ( ) . copied ( )
22+ match self {
23+ Self :: Function ( _, q) => Some ( * q) ,
24+ Self :: Sub ( _) => None ,
25+ }
3626 }
3727
3828 pub fn param_types ( & self ) -> & ResolvedParamTypes {
39- & self . param_types
29+ match self {
30+ Self :: Function ( param_types, _) => param_types,
31+ Self :: Sub ( param_types) => param_types,
32+ }
4033 }
4134}
4235
@@ -46,9 +39,12 @@ impl Signature {
4639
4740impl PartialEq < TypeQualifier > for Signature {
4841 fn eq ( & self , other : & TypeQualifier ) -> bool {
49- match & self . q {
50- Some ( q) => q == other,
51- _ => false ,
42+ if let Self :: Function ( _, q) = self
43+ && q == other
44+ {
45+ true
46+ } else {
47+ false
5248 }
5349 }
5450}
0 commit comments