pub fn guess_language<P: AsRef<Path>>(
buf: &[u8],
path: P,
) -> (Option<LANG>, String)
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 rust_code_analysis::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);