Skip to content

Commit

Permalink
Keep unwrap_or_default_log only.
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Sep 26, 2022
1 parent 1bd6bcb commit 45afb29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bins/ayaka-gui/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ fn get_actions(
let action = context
.get_action(&settings.lang, raw_ctx)
.unwrap_or_default_log("Cannot get action");
let base_action = settings.sub_lang.as_ref().and_then(|sub_lang| {
let base_action = settings.sub_lang.as_ref().map(|sub_lang| {
context
.get_action(sub_lang, raw_ctx)
.ok_or_log("Cannot get sub action")
.unwrap_or_default_log("Cannot get sub action")
});
(action, base_action)
}
Expand Down
12 changes: 0 additions & 12 deletions utils/ayaka-script/src/tryext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use std::{

#[doc(hidden)]
pub trait TryExt: Try {
fn ok_or_log(self, msg: &str) -> Option<Self::Output>;

fn unwrap_or_default_log(self, msg: &str) -> Self::Output;
}

Expand All @@ -16,16 +14,6 @@ where
T::Output: Default,
T::Residual: Debug,
{
fn ok_or_log(self, msg: &str) -> Option<Self::Output> {
match self.branch() {
ControlFlow::Continue(v) => Some(v),
ControlFlow::Break(e) => {
warn!("{msg}: {e:?}");
None
}
}
}

fn unwrap_or_default_log(self, msg: &str) -> Self::Output {
match self.branch() {
ControlFlow::Continue(v) => v,
Expand Down

0 comments on commit 45afb29

Please sign in to comment.