Function detect

Source
pub fn detect(path: &Path) -> Result<Option<Detection>, Error>
Expand description

Detects the programming language of the file at a given path

If the language cannot be determined, None will be returned. detect will error on an io error or if the parser returns an error when tokenizing the contents of the file

ยงExamples

use std::path::Path;
use hyperpolyglot::{detect, Detection};

let path = Path::new("src/bin/main.rs");
let language = detect(path).unwrap().unwrap();
assert_eq!(Detection::Heuristics("Rust"), language);