Changed unwrap_or to unwrap_or_else in some places.
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
This commit is contained in:
parent
38030ffb4e
commit
261ca04c92
14 changed files with 31 additions and 30 deletions
|
@ -282,7 +282,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
|||
let mut test_runner = cx
|
||||
.test_runner
|
||||
.clone()
|
||||
.unwrap_or(ecx.path(sp, vec![test_id, Ident::from_str_and_span(runner_name, sp)]));
|
||||
.unwrap_or_else(|| ecx.path(sp, vec![test_id, Ident::from_str_and_span(runner_name, sp)]));
|
||||
|
||||
test_runner.span = sp;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue