Simplify ChannelUnavailable APIError handling with let-else#4736
Simplify ChannelUnavailable APIError handling with let-else#4736Abeeujah wants to merge 2 commits into
Conversation
Refactor the nested match statement used during error construction into a more idiomatic let-else construct (stabilised in Rust 1.65). The previous implementation required verbose, nested matching to navigate around borrow checker limitations. By leveraging let-else alongside chaining unwrap_err on handle_error Result, we achieve the same teardown logic (dropping state locks) and error mapping with significantly less boilerplate and nesting.
Clippy errors when a manual implementation of `repeat` is used instead of the `str::repeat` method, especially for MSRV > `1.16.0`. Since our MSRV is `1.75.0` and `str::repeat` was stabilized in `1.16.0`, this commit fixes the three instances where Clippy triggered the `manual_str_repeat` lint.
|
I've assigned @valentinewallace as a reviewer! |
|
No issues found. Both changes are correct and behavior-preserving:
|
Hamza1610
left a comment
There was a problem hiding this comment.
Test Results: PASS
All tests passed successfully! However, there are a couple of minor warnings to address:
** Redundant Import in channelmanager.rs**
warning: the item Hasher is imported redundantly
--> lightning/src/ln/channelmanager.rs:19832:35
|
177 | use core::hash::{Hash, Hasher};
| ------ the item Hasher is already imported here
19832 | use core::hash::{BuildHasher, Hasher};
| ^^^^^^
Issue: Hasher is imported twice in the same file. Fix: Remove the redundant Hasher from line 19832, keeping only BuildHasher: use core::hash::{BuildHasher};
Overall: Tests pass |Only minor cleanup needed
|
When I was testing I noticed some ignored test. These might be deprecated test that are not in used anymore. I'm suggesting to create a new PR for this. @casey what do you think about that. |
Hi @Hamza1610 I appreciate the review! However, the unused import warning is actually unrelated to the changes in this PR. It looks like it was introduced to Given the ongoing Forgejo migration (#4734), it's probably best to avoid scope creep here to keep this PR clean and prevent untracked changes. |
e9e3060 Fixes the TODO for the error handling.
3d6a879 Fixes the triggered
manual_str_repeatlint.