Open pvonmoradi opened 2 years ago
[dependencies]
hyperpolyglot = { git = "https://github.com/StringKe/hyperpolyglot.git", branch = "master" }
fn main() {
let content = r#"
use clipboard_rs::{ClipboardContext, ClipboardHandler};
pub struct ClipboardManager {
ctx: ClipboardContext,
}
impl ClipboardManager {
pub fn new() -> Self {
Self {
ctx: ClipboardContext::new().unwrap(),
}
}
}
impl ClipboardHandler for ClipboardManager {
fn on_clipboard_change(&mut self) {
println!("Clipboard changed");
}
}
"#;
let result = hyperpolyglot::detectors::classify(content, &*vec![]);
println!("{}", result.to_string());
}
For example grab a C file, change its extension to
.go
. Allgithub-linguist
,enry
andhyperpolyglot
detect it as a Go source. If I remove the extension,hyperpolyglot
returns empty.