1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
pub use ;
/// Source-language detection result.
///
/// Use [`Detection::language`] to read the top language and
/// [`Detection::top_languages`] to iterate over ranked probability/language
/// pairs. [`Detection::language`] returns [`None`] when the input is empty,
/// effectively whitespace only, or too short to build the model window.
///
/// ```
/// let detection = betlang::detect("fn main() { println!(\"hi\"); }");
///
/// assert_eq!(detection.language(), Some(betlang::Language::Rust));
/// ```
/// Detect the source language for bytes-like input.
///
/// Use [`Language::slug`] to map predicted languages to Arborium/tree-sitter
/// identifiers. [`Detection::language`] returns [`None`] when the input is
/// empty, effectively whitespace only, or too short to build the model window.
/// The input may be a UTF-8 string, raw byte slice, or another type that can be
/// borrowed as bytes.
///
/// ```
/// let detection = betlang::detect("fn main() { println!(\"hi\"); }");
///
/// assert_eq!(detection.language(), Some(betlang::Language::Rust));
/// ```