ignore/types: add method for retrieving file type definition

Fixes #1116, Closes #1120
This commit is contained in:
Awad Mackie 2018-11-25 21:17:18 +00:00 committed by Andrew Gallant
parent 8fd05cacee
commit 44a9e37737
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44

View File

@ -350,6 +350,18 @@ impl<'a> Glob<'a> {
fn unmatched() -> Glob<'a> { fn unmatched() -> Glob<'a> {
Glob(GlobInner::UnmatchedIgnore) Glob(GlobInner::UnmatchedIgnore)
} }
/// Return the file type defintion that matched, if one exists. A file type
/// definition always exists when a specific definition matches a file
/// path.
pub fn file_type_def(&self) -> Option<&FileTypeDef> {
match self {
Glob(GlobInner::UnmatchedIgnore) => None,
Glob(GlobInner::Matched { def, .. }) => {
Some(def)
},
}
}
} }
/// A single file type definition. /// A single file type definition.