pub fn of<P>(
        &self,
        path: P,
    ) -> Option<&Vec<Owner>>
    where
        P: AsRef<Path>,
    {
        self.paths
            .iter()
            .filter_map(|mapping| {
                let &(ref pattern, ref owners) = mapping;
                let opts = glob::MatchOptions {
                    case_sensitive: false,
                    require_literal_separator: pattern.as_str().contains('/'),
                    require_literal_leading_dot: false,
                };
                if pattern.matches_path_with(path.as_ref(), opts) {
                    Some(owners)
                } else {
                    // this pattern is only meant to match
                    // direct children
                    if pattern.as_str().ends_with("/*") {
                        return None;
                    }
                    // case of implied owned children
                    // foo/bar @owner should indicate that foo/bar/baz.rs is
                    // owned by @owner
                    let mut p = path.as_ref();
                    while let Some(parent) = p.parent() {
                        if pattern.matches_path_with(parent, opts) {
                            return Some(owners);
                        } else {
                            p = parent;
                        }
                    }
                    None
                }
            })
            .next()
    }
/// Resolve a list of owners matching a given path
Resolve a list of owners matching a given path
Resolve a list of owners matching a given path
pub fn of<P>(
        &self,
        path: P,
    ) -> Option<&Vec<Owner>>
    where
        P: AsRef<Path>,
    {
        self.paths
            .iter()
            .filter_map(|mapping| {
                let &(ref pattern, ref owners) = mapping;
                let opts = glob::MatchOptions {
                    case_sensitive: false,
                    require_literal_separator: pattern.as_str().contains('/'),
                    require_literal_leading_dot: false,
                };
                if pattern.matches_path_with(path.as_ref(), opts) {
                    Some(owners)
                } else {
                    // this pattern is only meant to match
                    // direct children
                    if pattern.as_str().ends_with("/*") {
                        return None;
                    }
                    // case of implied owned children
                    // foo/bar @owner should indicate that foo/bar/baz.rs is
                    // owned by @owner
                    let mut p = path.as_ref();
                    while let Some(parent) = p.parent() {
                        if pattern.matches_path_with(parent, opts) {
                            return Some(owners);
                        } else {
                            p = parent;
                        }
                    }
                    None
                }
            })
            .next()
    }
pub fn of < P > ( & self , path : P , ) -> Option < & Vec < Owner > > where P : AsRef < Path > , { self . paths . iter ( ) . filter_map ( | mapping | { let & ( ref pattern , ref owners ) = mapping ; let opts = glob :: MatchOptions { case_sensitive : false , require_literal_separator : pattern . as_str ( ) . contains ( '/' ) , require_literal_leading_dot : false , } ; if pattern . matches_path_with ( path . as_ref ( ) , opts ) { Some ( owners ) } else { // this pattern is only meant to match // direct children if pattern . as_str ( ) . ends_with ( " " ) { return None ; } // case of implied owned children // foo/bar @owner should indicate that foo/bar/baz.rs is // owned by @owner let mut p = path . as_ref ( ) ; while let Some ( parent ) = p . parent ( ) { if pattern . matches_path_with ( parent , opts ) { return Some ( owners ) ; } else { p = parent ; } } None } } ) . next ( ) }
Resolve a list of owners matching a given path
Resolve a list of owners matching a given path
&self
path
P
&self
path
P