File tree Expand file tree Collapse file tree 5 files changed +33
-0
lines changed Expand file tree Collapse file tree 5 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
8
8
## Unreleased
9
9
10
+ - add ` maybe_array ` constructors
10
11
- Bump MSRV to 1.65.0
11
12
- Bump ` regex ` to 1.10
12
13
Original file line number Diff line number Diff line change @@ -203,6 +203,14 @@ impl ClusterInfo {
203
203
pub const fn array ( self , dim : DimElement ) -> Cluster {
204
204
Cluster :: Array ( self , dim)
205
205
}
206
+ /// Construct single [`Cluster`] or array
207
+ pub fn maybe_array ( self , dim : Option < DimElement > ) -> Cluster {
208
+ if let Some ( dim) = dim {
209
+ self . array ( dim)
210
+ } else {
211
+ self . single ( )
212
+ }
213
+ }
206
214
/// Modify an existing [`ClusterInfo`] based on a [builder](ClusterInfoBuilder).
207
215
pub fn modify_from (
208
216
& mut self ,
Original file line number Diff line number Diff line change @@ -248,6 +248,14 @@ impl FieldInfo {
248
248
pub const fn array ( self , dim : DimElement ) -> Field {
249
249
Field :: Array ( self , dim)
250
250
}
251
+ /// Construct single [`Field`] or array
252
+ pub fn maybe_array ( self , dim : Option < DimElement > ) -> Field {
253
+ if let Some ( dim) = dim {
254
+ self . array ( dim)
255
+ } else {
256
+ self . single ( )
257
+ }
258
+ }
251
259
/// Modify an existing [`FieldInfo`] based on a [builder](FieldInfoBuilder).
252
260
pub fn modify_from (
253
261
& mut self ,
Original file line number Diff line number Diff line change @@ -313,6 +313,14 @@ impl PeripheralInfo {
313
313
pub const fn array ( self , dim : DimElement ) -> Peripheral {
314
314
Peripheral :: Array ( self , dim)
315
315
}
316
+ /// Construct single [`Peripheral`] or array
317
+ pub fn maybe_array ( self , dim : Option < DimElement > ) -> Peripheral {
318
+ if let Some ( dim) = dim {
319
+ self . array ( dim)
320
+ } else {
321
+ self . single ( )
322
+ }
323
+ }
316
324
/// Modify an existing [`Peripheral`] based on a [builder](PeripheralInfoBuilder).
317
325
pub fn modify_from (
318
326
& mut self ,
Original file line number Diff line number Diff line change @@ -288,6 +288,14 @@ impl RegisterInfo {
288
288
pub const fn array ( self , dim : DimElement ) -> Register {
289
289
Register :: Array ( self , dim)
290
290
}
291
+ /// Construct single [`Register`] or array
292
+ pub fn maybe_array ( self , dim : Option < DimElement > ) -> Register {
293
+ if let Some ( dim) = dim {
294
+ self . array ( dim)
295
+ } else {
296
+ self . single ( )
297
+ }
298
+ }
291
299
/// Modify an existing [`RegisterInfo`] based on a [builder](RegisterInfoBuilder).
292
300
pub fn modify_from (
293
301
& mut self ,
You can’t perform that action at this time.
0 commit comments