| Crates.io | languages |
| lib.rs | languages |
| version | 0.0.2 |
| created_at | 2025-07-25 05:58:19.176723+00 |
| updated_at | 2025-07-25 06:58:08.074289+00 |
| description | GitHub's language data, compiled into a tiny, fast Rust library |
| homepage | |
| repository | https://github.com/cortesi/languages |
| max_upload_size | |
| id | 1767233 |
| size | 174,930 |
GitHub's language data, compiled into a tiny, fast Rust library. 🦀
This crate provides an efficient way to look up language information from
GitHub's Linguist languages.yml file. The data is parsed at compile-time and
baked directly into your binary, making lookups instantaneous with zero runtime
overhead.
HashMaps for instant, case-insensitive lookups.Add languages to your Cargo.toml:
[dependencies]
languages = "0.1.0" # Replace with the latest version
Use the lookup functions:
let lang = languages::from_extension("rs").unwrap();
assert_eq!(lang.name, "Rust");
assert_eq!(lang.language_type, "programming");
assert_eq!(lang.color, Some("#dea584"));
// Look up by name (case-insensitive)
let python = languages::from_name("Python").unwrap();
assert!(python.extensions.unwrap().contains(&".py"));
// Look up by alias
let cpp = languages::from_name("cpp").unwrap();
assert_eq!(cpp.name, "C++");
This crate uses a build.rs script that parses languages.yml and generates
the necessary Rust code. To update the language data to the latest version from
GitHub, simply run the download_languages.sh script and recompile your
project.
This library was written to be used in the snips tool, which is also used to maintain the code examples in this README.
The code for the languages crate is licensed under the MIT License.
The language data is sourced from the GitHub Linguist project, which is distributed under the MIT license and is copyright of GitHub, Inc.