Skip to content
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

Remove some unwraps #36

Merged
merged 1 commit into from
Mar 2, 2024
Merged

Remove some unwraps #36

merged 1 commit into from
Mar 2, 2024

Conversation

LouisDISPA
Copy link
Contributor

While reading the whole codebase to try to understand how to solve the color issue I found some unneeded unwraps.

This don't change any logic since the unwraps they are checked before using them.
This is more a style preference. (I like clean Rust 😄)

One advantage is when searching for unwraps and except, now only the unchecked one are listed.

Follow up on #35, need it to be merge before reviewing.

.expect("There should be a color context here")
.InitializeFromMemory(&decoded.icc[..])?;
if let Some(context) = ppicolorcontexts.as_mut() {
if ccount == 1 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can even do tuple match? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried matching and if let a tuple but I found them less readable than just nesting if. Sadly chaining if let is not stable yet.

Suggested change
if ccount == 1 {
if let (Some(context), 1) = (ppicolorcontexts.as_mut(), ccount) {

Use pattern matching to avoid .is_none() and .unwrap()
@LouisDISPA
Copy link
Contributor Author

Wow you fixed the color issues!!! Amazing thank you so much!
It works perfectly on my machine.

@LouisDISPA LouisDISPA marked this pull request as ready for review March 1, 2024 12:59
Copy link
Owner

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍

@saschanaz saschanaz merged commit d091fef into saschanaz:main Mar 2, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants