Skip to content

Eliminate the function call in xxx_or (e.g. unwrap_or("".to_string()) #15802

Closed
@Rachelint

Description

@Rachelint

Is your feature request related to a problem or challenge?

I found some unnecessary functions are called, due to using unwrap_or rather than unwrap_or_else in funcation call case (some fucntion calls may be not really cheap).
I have eliminate some of them in SessionStateBuilder::build(#15800 ), but I think we should use lints to ensure it.

Describe the solution you'd like

  • Add or_fun_call lint to crates
  • Make clippy again by eliminating the function call in unwrap_or
  • It is better to also add unnecessary_lazy_evaluations to avoid abusing unwrap_or_else

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions