1
1
//! Implementations of DeriveFrom, setting non-explicit fields.
2
2
use crate :: {
3
- ClusterInfo , EnumeratedValues , FieldInfo , MaybeArray , PeripheralInfo , RegisterInfo ,
3
+ ClusterInfo ,
4
+ DimElement ,
5
+ EnumeratedValues ,
6
+ FieldInfo ,
7
+ MaybeArray ,
8
+ PeripheralInfo ,
9
+ RegisterInfo ,
4
10
RegisterProperties ,
5
11
} ;
6
12
@@ -110,6 +116,20 @@ impl DeriveFrom for FieldInfo {
110
116
}
111
117
}
112
118
119
+ impl DeriveFrom for DimElement {
120
+ fn derive_from ( & self , other : & Self ) -> Self {
121
+ let mut derived = self . clone ( ) ;
122
+ derived. dim = other. dim ;
123
+ derived. dim_increment = other. dim_increment ;
124
+ derived. dim_index = derived. dim_index . or_else ( || other. dim_index . clone ( ) ) ;
125
+ derived. dim_name = derived. dim_name . or_else ( || other. dim_name . clone ( ) ) ;
126
+ derived. dim_array_index = derived
127
+ . dim_array_index
128
+ . or_else ( || other. dim_array_index . clone ( ) ) ;
129
+ derived
130
+ }
131
+ }
132
+
113
133
impl < T > DeriveFrom for MaybeArray < T >
114
134
where
115
135
T : DeriveFrom + crate :: Name ,
@@ -128,9 +148,12 @@ where
128
148
Self :: Single ( info. derive_from ( other_info) )
129
149
}
130
150
}
131
- ( Self :: Array ( info, dim) , Self :: Single ( other_info) | Self :: Array ( other_info , _ ) ) => {
151
+ ( Self :: Array ( info, dim) , Self :: Single ( other_info) ) => {
132
152
Self :: Array ( info. derive_from ( other_info) , dim. clone ( ) )
133
153
}
154
+ ( Self :: Array ( info, dim) , Self :: Array ( other_info, other_dim) ) => {
155
+ Self :: Array ( info. derive_from ( other_info) , dim. derive_from ( other_dim) )
156
+ }
134
157
}
135
158
}
136
159
}
0 commit comments