Skip to main content

guess_language

Function guess_language 

Source
pub fn guess_language<P>(buf: &[u8], path: P) -> (Option<LANG>, &'static str)
where P: AsRef<Path>,
Expand description

Guesses the language of a code.

Returns a tuple containing a LANG as first argument and the language name as a second one.

ยงExamples

use std::path::PathBuf;

use big_code_analysis_ast::guess_language;

let source_code = "int a = 42;";

// The path to a dummy file used to contain the source code
let path = PathBuf::from("foo.c");
let source_slice = source_code.as_bytes();

// Guess the language of a code
guess_language(&source_slice, &path);