refac: prevent a panic
This commit is contained in:
parent
f9c55ce074
commit
fac102e6be
1 changed files with 4 additions and 4 deletions
|
@ -1,5 +1,4 @@
|
||||||
use super::StreamCommand;
|
use super::StreamCommand;
|
||||||
use whatlang::{detect};
|
|
||||||
use crate::result::*;
|
use crate::result::*;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
@ -35,9 +34,10 @@ impl StreamCommand for QueryCommand<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// use greyblake/whatlang-rs to autodect locale
|
// use greyblake/whatlang-rs to autodect locale
|
||||||
let text = detect(self.terms).unwrap();
|
if let Some(info) = whatlang::detect(self.terms) {
|
||||||
if text.confidence() == 1.0 {
|
if info.confidence() == 1.0 {
|
||||||
message.push_str(&format!(" LANG({})", text.lang().code()));
|
message.push_str(&format!(" LANG({})", info.lang().code()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.push_str("\r\n");
|
message.push_str("\r\n");
|
||||||
|
|
Loading…
Reference in a new issue