Skip to content

Commit

Permalink
feat(rsjudge-utils): ♻️ use inspect_err from Rust v1.76.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Jun 29, 2024
1 parent a1a9527 commit 5abeaca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions crates/rsjudge-utils/src/error_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
#[macro_export]
macro_rules! log_if_error {
($expr: expr) => {
::std::result::Result::map_err($expr, |err| {
::std::result::Result::inspect_err($expr, |err| {
::log::error!("{}", err);
err
})
};
}
4 changes: 2 additions & 2 deletions crates/rsjudge-utils/tests/cases/logging_on_non_result.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ error[E0308]: mismatched types
note: method defined here
--> $RUST/core/src/result.rs
|
| pub fn map_err<F, O: FnOnce(E) -> F>(self, op: O) -> Result<T, F> {
| ^^^^^^^
| pub fn inspect_err<F: FnOnce(&E)>(self, f: F) -> Self {
| ^^^^^^^^^^^
help: try wrapping the expression in a variant of `Result`
|
21 | let _ = log_if_error!(Ok(S));
Expand Down

0 comments on commit 5abeaca

Please sign in to comment.