Skip to content

Suggest unwrap_or_default when returning empty String in closure #9420

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

Closed
xphoniex opened this issue Sep 3, 2022 · 0 comments · Fixed by #9421
Closed

Suggest unwrap_or_default when returning empty String in closure #9420

xphoniex opened this issue Sep 3, 2022 · 0 comments · Fixed by #9421
Assignees

Comments

@xphoniex
Copy link
Contributor

xphoniex commented Sep 3, 2022

Description

Clippy accepts this atm:

empty_string.unwrap_or_else(|| "".to_string());

It should suggest unwrap_or_default for this case, which is more concise:

empty_string.unwrap_or_default();

Version

No response

Additional Labels

@rustbot claim

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 a pull request may close this issue.

1 participant