@@ -12,40 +12,36 @@ impl TeamGlobMapper {
1212 pub fn build ( project : Arc < Project > ) -> Self {
1313 Self { project }
1414 }
15+
16+ fn iter_team_globs ( & self ) -> impl Iterator < Item = ( & str , & str , & str , bool ) > + ' _ {
17+ self . project . teams . iter ( ) . flat_map ( |team| {
18+ team. owned_globs
19+ . iter ( )
20+ . map ( move |glob| ( glob. as_str ( ) , team. github_team . as_str ( ) , team. name . as_str ( ) , team. avoid_ownership ) )
21+ } )
22+ }
1523}
1624
1725impl Mapper for TeamGlobMapper {
1826 fn entries ( & self ) -> Vec < Entry > {
19- let mut entries: Vec < Entry > = Vec :: new ( ) ;
20-
21- for team in & self . project . teams {
22- for owned_glob in & team. owned_globs {
23- entries. push ( Entry {
24- path : owned_glob. to_owned ( ) ,
25- github_team : team. github_team . to_owned ( ) ,
26- team_name : team. name . to_owned ( ) ,
27- disabled : team. avoid_ownership ,
28- } ) ;
29- }
30- }
31-
32- entries
27+ self . iter_team_globs ( )
28+ . map ( |( glob, github_team, team_name, disabled) | Entry {
29+ path : glob. to_owned ( ) ,
30+ github_team : github_team. to_owned ( ) ,
31+ team_name : team_name. to_owned ( ) ,
32+ disabled,
33+ } )
34+ . collect ( )
3335 }
3436
3537 fn owner_matchers ( & self ) -> Vec < OwnerMatcher > {
36- let mut owner_matchers: Vec < OwnerMatcher > = Vec :: new ( ) ;
37-
38- for team in & self . project . teams {
39- for owned_glob in & team. owned_globs {
40- owner_matchers. push ( OwnerMatcher :: Glob {
41- glob : owned_glob. clone ( ) ,
42- team_name : team. github_team . clone ( ) ,
43- source : Source :: TeamGlob ( owned_glob. clone ( ) ) ,
44- } )
45- }
46- }
47-
48- owner_matchers
38+ self . iter_team_globs ( )
39+ . map ( |( glob, github_team, _, _) | OwnerMatcher :: Glob {
40+ glob : glob. to_owned ( ) ,
41+ team_name : github_team. to_owned ( ) ,
42+ source : Source :: TeamGlob ( glob. to_owned ( ) ) ,
43+ } )
44+ . collect ( )
4945 }
5046
5147 fn name ( & self ) -> String {
0 commit comments