detect-lang
This crate is a utility for identifying names of programming languages (and related files) from paths and file extensions.
This is not a crate for detecting natural languages.
Usage
Add this to your Cargo.toml
:
[]
= "0.1"
Paths and Extensions
Languages can be identified from paths using from_path
or directly from extensions using from_extension
.
use from_path;
assert_eq!;
assert_eq!;
use from_extension;
assert_eq!;
assert_eq!;
// The case is ignored
assert_eq!;
assert_eq!;
Language ID
In short, the language id
is a lowercase version of name
.
However, it also replaces symbols making it usable as a URL slug.
For instance foo.hpp
is identified as language name C++
and
language ID cpp
.
use from_path;
assert_eq!;
assert_eq!;
assert_eq!;
use from_extension;
assert_eq!;
assert_eq!;
assert_eq!;
// The case is ignored
assert_eq!;
assert_eq!;
Match Example
use Path;
use ;
let path = new;
match from_path