[−][src]Function detect_lang::from_path
pub fn from_path<P: AsRef<Path>>(path: P) -> Option<Language<'static>>
Identifies the language from a path. The casing of the extension does not affect the result.
Note that from_path
does not check if the path exists.
Example
assert_eq!(from_path("foo.rs"), Some(Language("Rust", "rust"))); assert_eq!(from_path("foo.md"), Some(Language("Markdown", "markdown"))); assert_eq!(from_path("foo.cpp"), Some(Language("C++", "cpp"))); assert_eq!(from_path("foo.unknown"), None); // The case is ignored assert_eq!(from_path("foo.jSoN"), Some(Language("JSON", "json")));