@@ -5,8 +5,7 @@ use std::collections::HashMap;
55use  std:: fmt; 
66use  std:: mem:: take; 
77use  svd_rs:: { 
8-     array:: { descriptions,  names} , 
9-     cluster,  field,  peripheral,  register,  BitRange ,  Cluster ,  ClusterInfo ,  DeriveFrom ,  Device , 
8+     array:: names,  cluster,  field,  peripheral,  register,  Cluster ,  ClusterInfo ,  DeriveFrom ,  Device , 
109    EnumeratedValues ,  Field ,  Peripheral ,  Register ,  RegisterCluster ,  RegisterProperties , 
1110} ; 
1211
@@ -320,17 +319,7 @@ fn expand_cluster_array(
320319    match  c { 
321320        Cluster :: Single ( c)  => expand_cluster ( regs,  c) , 
322321        Cluster :: Array ( info,  dim)  => { 
323-             for  c in  names ( & info,  & dim) 
324-                 . zip ( descriptions ( & info,  & dim) ) 
325-                 . zip ( cluster:: address_offsets ( & info,  & dim) ) 
326-                 . map ( |( ( name,  description) ,  address_offset) | { 
327-                     let  mut  info = info. clone ( ) ; 
328-                     info. name  = name; 
329-                     info. description  = description; 
330-                     info. address_offset  = address_offset; 
331-                     info
332-                 } ) 
333-             { 
322+             for  c in  cluster:: expand ( & info,  & dim)  { 
334323                expand_cluster ( regs,  c) ; 
335324            } 
336325        } 
@@ -468,19 +457,7 @@ fn expand_register_array(
468457            regs. push ( r. into ( ) ) ; 
469458        } 
470459        Register :: Array ( info,  dim)  => { 
471-             for  rx in  names ( & info,  & dim) 
472-                 . zip ( descriptions ( & info,  & dim) ) 
473-                 . zip ( register:: address_offsets ( & info,  & dim) ) 
474-                 . map ( |( ( name,  description) ,  address_offset) | { 
475-                     let  mut  info = info. clone ( ) ; 
476-                     info. name  = name; 
477-                     info. description  = description; 
478-                     info. address_offset  = address_offset; 
479-                     info. single ( ) 
480-                 } ) 
481-             { 
482-                 regs. push ( rx. into ( ) ) ; 
483-             } 
460+             regs. extend ( register:: expand ( & info,  & dim) . map ( |r| r. single ( ) . into ( ) ) ) ; 
484461        } 
485462    } 
486463    Ok ( ( ) ) 
@@ -511,19 +488,7 @@ fn expand_field(
511488            fields. push ( f) ; 
512489        } 
513490        Field :: Array ( info,  dim)  => { 
514-             for  fx in  names ( & info,  & dim) 
515-                 . zip ( descriptions ( & info,  & dim) ) 
516-                 . zip ( field:: bit_offsets ( & info,  & dim) ) 
517-                 . map ( |( ( name,  description) ,  bit_offset) | { 
518-                     let  mut  info = info. clone ( ) ; 
519-                     info. name  = name; 
520-                     info. description  = description; 
521-                     info. bit_range  = BitRange :: from_offset_width ( bit_offset,  info. bit_width ( ) ) ; 
522-                     Field :: Single ( info) 
523-                 } ) 
524-             { 
525-                 fields. push ( fx) ; 
526-             } 
491+             fields. extend ( field:: expand ( & info,  & dim) . map ( Field :: Single ) ) ; 
527492        } 
528493    } 
529494
@@ -636,19 +601,9 @@ pub fn expand(indevice: &Device) -> Result<Device> {
636601                device. peripherals . push ( p) ; 
637602            } 
638603            Peripheral :: Array ( info,  dim)  => { 
639-                 for  px in  names ( & info,  & dim) 
640-                     . zip ( descriptions ( & info,  & dim) ) 
641-                     . zip ( peripheral:: base_addresses ( & info,  & dim) ) 
642-                     . map ( |( ( name,  description) ,  base_address) | { 
643-                         let  mut  info = info. clone ( ) ; 
644-                         info. name  = name; 
645-                         info. description  = description; 
646-                         info. base_address  = base_address; 
647-                         Peripheral :: Single ( info) 
648-                     } ) 
649-                 { 
650-                     device. peripherals . push ( px) ; 
651-                 } 
604+                 device
605+                     . peripherals 
606+                     . extend ( peripheral:: expand ( & info,  & dim) . map ( Peripheral :: Single ) ) ; 
652607            } 
653608        } 
654609    } 
0 commit comments