@@ -10,8 +10,8 @@ use std::path::{Path, PathBuf};
1010#[ derive( serde:: Serialize ) ]
1111#[ serde( rename_all = "kebab-case" , tag = "type" ) ]
1212pub ( crate ) enum Node < L > {
13- Root { childs : Vec < Node < L > > } ,
14- Directory { name : PathBuf , childs : Vec < Node < L > > , license : Option < L > } ,
13+ Root { children : Vec < Node < L > > } ,
14+ Directory { name : PathBuf , children : Vec < Node < L > > , license : Option < L > } ,
1515 File { name : PathBuf , license : L } ,
1616 Group { files : Vec < PathBuf > , directories : Vec < PathBuf > , license : L } ,
1717 Empty ,
@@ -48,14 +48,14 @@ impl Node<LicenseId> {
4848 /// ```
4949 fn merge_directories ( & mut self ) {
5050 match self {
51- Node :: Root { childs } | Node :: Directory { childs , license : None , .. } => {
51+ Node :: Root { children } | Node :: Directory { children , license : None , .. } => {
5252 let mut directories = BTreeMap :: new ( ) ;
5353 let mut files = Vec :: new ( ) ;
5454
55- for child in childs . drain ( ..) {
55+ for child in children . drain ( ..) {
5656 match child {
57- Node :: Directory { name, mut childs , license : None } => {
58- directories. entry ( name) . or_insert_with ( Vec :: new) . append ( & mut childs ) ;
57+ Node :: Directory { name, mut children , license : None } => {
58+ directories. entry ( name) . or_insert_with ( Vec :: new) . append ( & mut children ) ;
5959 }
6060 file @ Node :: File { .. } => {
6161 files. push ( file) ;
@@ -73,14 +73,14 @@ impl Node<LicenseId> {
7373 }
7474 }
7575
76- childs . extend ( directories. into_iter ( ) . map ( |( name, childs ) | Node :: Directory {
76+ children . extend ( directories. into_iter ( ) . map ( |( name, children ) | Node :: Directory {
7777 name,
78- childs ,
78+ children ,
7979 license : None ,
8080 } ) ) ;
81- childs . append ( & mut files) ;
81+ children . append ( & mut files) ;
8282
83- for child in & mut * childs {
83+ for child in & mut * children {
8484 child. merge_directories ( ) ;
8585 }
8686 }
@@ -105,13 +105,13 @@ impl Node<LicenseId> {
105105 /// our inclusion of LLVM.
106106 fn collapse_in_licensed_directories ( & mut self ) {
107107 match self {
108- Node :: Directory { childs , license, .. } => {
109- for child in & mut * childs {
108+ Node :: Directory { children , license, .. } => {
109+ for child in & mut * children {
110110 child. collapse_in_licensed_directories ( ) ;
111111 }
112112
113113 let mut licenses_count = BTreeMap :: new ( ) ;
114- for child in & * childs {
114+ for child in & * children {
115115 let Some ( license) = child. license ( ) else { continue } ;
116116 * licenses_count. entry ( license) . or_insert ( 0 ) += 1 ;
117117 }
@@ -122,12 +122,12 @@ impl Node<LicenseId> {
122122 . map ( |( license, _) | license) ;
123123
124124 if let Some ( most_popular_license) = most_popular_license {
125- childs . retain ( |child| child. license ( ) != Some ( most_popular_license) ) ;
125+ children . retain ( |child| child. license ( ) != Some ( most_popular_license) ) ;
126126 * license = Some ( most_popular_license) ;
127127 }
128128 }
129- Node :: Root { childs } => {
130- for child in & mut * childs {
129+ Node :: Root { children } => {
130+ for child in & mut * children {
131131 child. collapse_in_licensed_directories ( ) ;
132132 }
133133 }
@@ -138,29 +138,29 @@ impl Node<LicenseId> {
138138 }
139139
140140 /// Reduce the depth of the tree by merging subdirectories with the same license as their
141- /// parent directory into their parent, and adjusting the paths of the childs accordingly.
141+ /// parent directory into their parent, and adjusting the paths of the children accordingly.
142142 fn merge_directory_licenses ( & mut self ) {
143143 match self {
144- Node :: Root { childs } => {
145- for child in & mut * childs {
144+ Node :: Root { children } => {
145+ for child in & mut * children {
146146 child. merge_directory_licenses ( ) ;
147147 }
148148 }
149- Node :: Directory { childs , license, .. } => {
149+ Node :: Directory { children , license, .. } => {
150150 let mut to_add = Vec :: new ( ) ;
151- for child in & mut * childs {
151+ for child in & mut * children {
152152 child. merge_directory_licenses ( ) ;
153153
154154 let Node :: Directory {
155155 name : child_name,
156- childs : child_childs ,
156+ children : child_children ,
157157 license : child_license,
158158 } = child else { continue } ;
159159
160160 if child_license != license {
161161 continue ;
162162 }
163- for mut child_child in child_childs . drain ( ..) {
163+ for mut child_child in child_children . drain ( ..) {
164164 match & mut child_child {
165165 Node :: Root { .. } => {
166166 panic ! ( "can't have a root inside another element" ) ;
@@ -181,7 +181,7 @@ impl Node<LicenseId> {
181181
182182 * child = Node :: Empty ;
183183 }
184- childs . append ( & mut to_add) ;
184+ children . append ( & mut to_add) ;
185185 }
186186 Node :: Empty => { }
187187 Node :: File { .. } => { }
@@ -203,14 +203,14 @@ impl Node<LicenseId> {
203203 directories : Vec < PathBuf > ,
204204 }
205205 match self {
206- Node :: Root { childs } | Node :: Directory { childs , .. } => {
206+ Node :: Root { children } | Node :: Directory { children , .. } => {
207207 let mut grouped: BTreeMap < LicenseId , Grouped > = BTreeMap :: new ( ) ;
208208
209- for child in & mut * childs {
209+ for child in & mut * children {
210210 child. merge_groups ( ) ;
211211 match child {
212- Node :: Directory { name, childs , license : Some ( license) } => {
213- if childs . is_empty ( ) {
212+ Node :: Directory { name, children , license : Some ( license) } => {
213+ if children . is_empty ( ) {
214214 grouped
215215 . entry ( * license)
216216 . or_insert_with ( Grouped :: default)
@@ -234,16 +234,16 @@ impl Node<LicenseId> {
234234 for ( license, mut grouped) in grouped. into_iter ( ) {
235235 if grouped. files . len ( ) + grouped. directories . len ( ) <= 1 {
236236 if let Some ( name) = grouped. files . pop ( ) {
237- childs . push ( Node :: File { license, name } ) ;
237+ children . push ( Node :: File { license, name } ) ;
238238 } else if let Some ( name) = grouped. directories . pop ( ) {
239- childs . push ( Node :: Directory {
239+ children . push ( Node :: Directory {
240240 name,
241- childs : Vec :: new ( ) ,
241+ children : Vec :: new ( ) ,
242242 license : Some ( license) ,
243243 } ) ;
244244 }
245245 } else {
246- childs . push ( Node :: Group {
246+ children . push ( Node :: Group {
247247 license,
248248 files : grouped. files ,
249249 directories : grouped. directories ,
@@ -261,11 +261,11 @@ impl Node<LicenseId> {
261261 /// sure to remove them from the tree.
262262 fn remove_empty ( & mut self ) {
263263 match self {
264- Node :: Root { childs } | Node :: Directory { childs , .. } => {
265- for child in & mut * childs {
264+ Node :: Root { children } | Node :: Directory { children , .. } => {
265+ for child in & mut * children {
266266 child. remove_empty ( ) ;
267267 }
268- childs . retain ( |child| !matches ! ( child, Node :: Empty ) ) ;
268+ children . retain ( |child| !matches ! ( child, Node :: Empty ) ) ;
269269 }
270270 Node :: Group { .. } => { }
271271 Node :: File { .. } => { }
@@ -275,7 +275,7 @@ impl Node<LicenseId> {
275275
276276 fn license ( & self ) -> Option < LicenseId > {
277277 match self {
278- Node :: Directory { childs , license : Some ( license) , .. } if childs . is_empty ( ) => {
278+ Node :: Directory { children , license : Some ( license) , .. } if children . is_empty ( ) => {
279279 Some ( * license)
280280 }
281281 Node :: File { license, .. } => Some ( * license) ,
@@ -285,7 +285,7 @@ impl Node<LicenseId> {
285285}
286286
287287pub ( crate ) fn build ( mut input : Vec < ( PathBuf , LicenseId ) > ) -> Node < LicenseId > {
288- let mut childs = Vec :: new ( ) ;
288+ let mut children = Vec :: new ( ) ;
289289
290290 // Ensure reproducibility of all future steps.
291291 input. sort ( ) ;
@@ -295,15 +295,15 @@ pub(crate) fn build(mut input: Vec<(PathBuf, LicenseId)>) -> Node<LicenseId> {
295295 for component in path. parent ( ) . unwrap_or_else ( || Path :: new ( "." ) ) . components ( ) . rev ( ) {
296296 node = Node :: Directory {
297297 name : component. as_os_str ( ) . into ( ) ,
298- childs : vec ! [ node] ,
298+ children : vec ! [ node] ,
299299 license : None ,
300300 } ;
301301 }
302302
303- childs . push ( node) ;
303+ children . push ( node) ;
304304 }
305305
306- Node :: Root { childs }
306+ Node :: Root { children }
307307}
308308
309309/// Convert a `Node<LicenseId>` into a `Node<&License>`, expanding all interned license IDs with a
@@ -313,14 +313,14 @@ pub(crate) fn expand_interned_licenses(
313313 interner : & LicensesInterner ,
314314) -> Node < & License > {
315315 match node {
316- Node :: Root { childs } => Node :: Root {
317- childs : childs
316+ Node :: Root { children } => Node :: Root {
317+ children : children
318318 . into_iter ( )
319319 . map ( |child| expand_interned_licenses ( child, interner) )
320320 . collect ( ) ,
321321 } ,
322- Node :: Directory { name, childs , license } => Node :: Directory {
323- childs : childs
322+ Node :: Directory { name, children , license } => Node :: Directory {
323+ children : children
324324 . into_iter ( )
325325 . map ( |child| expand_interned_licenses ( child, interner) )
326326 . collect ( ) ,
0 commit comments