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

chore(components/config): cleanup code #2592

Merged
merged 1 commit into from
Aug 7, 2024
Merged

Conversation

samueltardieu
Copy link
Contributor

Cleanup code by using Option::is_some_and() and Option::as_deref() instead of recoding them.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

Cleanup code by using `Option::is_some_and()` and
`Option::as_deref()` instead of recoding them.
Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

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

Thanks!

} else {
false
}
self.paginate_by.is_some_and(|paginate_by| paginate_by > 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL about is_some_and

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method name is explicit but uncommon. It is often called exists() (for example in Scala) in other functional languages, because it can be applied to construct of more than one element, such as lists, with the same semantics.

I've also seen self.paginate_by.into_iter().any(|paginate_by| paginate_by > 0) used before is_some_and() was introduced.

@Keats Keats merged commit 4fa15ee into getzola:next Aug 7, 2024
5 checks passed
reujab pushed a commit to reujab/zola that referenced this pull request Aug 14, 2024
Cleanup code by using `Option::is_some_and()` and
`Option::as_deref()` instead of recoding them.
Keats pushed a commit that referenced this pull request Aug 15, 2024
Cleanup code by using `Option::is_some_and()` and
`Option::as_deref()` instead of recoding them.
berdandy pushed a commit to berdandy/azola that referenced this pull request Sep 17, 2024
Cleanup code by using `Option::is_some_and()` and
`Option::as_deref()` instead of recoding them.
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