-
Notifications
You must be signed in to change notification settings - Fork 409
Rework unwrap()
call in persistence
#1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework unwrap()
call in persistence
#1941
Conversation
9e52f3e
to
66046a7
Compare
Codecov ReportBase: 90.74% // Head: 90.72% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1941 +/- ##
==========================================
- Coverage 90.74% 90.72% -0.03%
==========================================
Files 96 96
Lines 50133 50135 +2
Branches 50133 50135 +2
==========================================
- Hits 45493 45483 -10
- Misses 4640 4652 +12
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks.
lightning-persister/src/lib.rs
Outdated
let filename = owned_file_name.to_str(); | ||
if !filename.is_some() || !filename.unwrap().is_ascii() || filename.unwrap().len() < 65 { | ||
let filename = owned_file_name.to_str() | ||
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indent with a single tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. It is a work for fmt
of course... ;)
lightning-persister/src/lib.rs
Outdated
if !filename.is_some() || !filename.unwrap().is_ascii() || filename.unwrap().len() < 65 { | ||
let filename = owned_file_name.to_str() | ||
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, | ||
"File name is not a valid utf8 string"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, no need to push this to the end of the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
66046a7
to
a320ebc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one!
Use idiomatic
Result::map_err()
andOption::ok_or_else()
instead of nakedunwrap()
.