remove expect
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
4edcf4c412
commit
97718b33a6
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -5386,7 +5386,7 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||
[[package]]
|
||||
name = "tfc"
|
||||
version = "0.6.1"
|
||||
source = "git+https://github.com/asur4s/The-Fat-Controller#48303c5dacded6ea1873bc5d69bdde3175cf336a"
|
||||
source = "git+https://github.com/fufesou/The-Fat-Controller#48303c5dacded6ea1873bc5d69bdde3175cf336a"
|
||||
dependencies = [
|
||||
"core-graphics 0.22.3",
|
||||
"unicode-segmentation",
|
||||
|
@ -23,7 +23,7 @@ serde = { version = "1.0", optional = true }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
log = "0.4"
|
||||
rdev = { git = "https://github.com/fufesou/rdev" }
|
||||
tfc = { git = "https://github.com/asur4s/The-Fat-Controller" }
|
||||
tfc = { git = "https://github.com/fufesou/The-Fat-Controller" }
|
||||
hbb_common = { path = "../hbb_common" }
|
||||
|
||||
[features]
|
||||
|
@ -447,8 +447,9 @@ pub trait KeyboardControllable {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.key_sequence_parse_try(sequence)
|
||||
.expect("Could not parse sequence");
|
||||
if let Err(..) = self.key_sequence_parse_try(sequence) {
|
||||
println!("Could not parse sequence");
|
||||
}
|
||||
}
|
||||
/// Same as key_sequence_parse except returns any errors
|
||||
fn key_sequence_parse_try(&mut self, sequence: &str) -> Result<(), dsl::ParseError>
|
||||
|
@ -88,7 +88,13 @@ impl Default for Enigo {
|
||||
Self {
|
||||
is_x11,
|
||||
tfc: if is_x11 {
|
||||
Some(TFC_Context::new().expect("kbd context error"))
|
||||
match TFC_Context::new() {
|
||||
Ok(ctx) => Some(ctx),
|
||||
Err(..) => {
|
||||
println!("kbd context error");
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
@ -391,8 +391,9 @@ impl KeyboardControllable for EnigoXdo {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.key_sequence_parse_try(sequence)
|
||||
.expect("Could not parse sequence");
|
||||
if let Err(..) = self.key_sequence_parse_try(sequence) {
|
||||
println!("Could not parse sequence");
|
||||
}
|
||||
}
|
||||
|
||||
fn key_sequence_parse_try(&mut self, sequence: &str) -> Result<(), crate::dsl::ParseError>
|
||||
|
Loading…
x
Reference in New Issue
Block a user