Prefer unwrap_or_else to unwrap_or in case of function calls/allocations

This commit is contained in:
ljedrz 2018-10-12 16:16:00 +02:00
parent cb5e1b93e3
commit d28aed6dc4
35 changed files with 57 additions and 54 deletions

View file

@ -942,7 +942,8 @@ impl SourceMap {
} else {
format!("{}<", &snippet[..offset])
};
new_snippet.push_str(&self.span_to_snippet(span).unwrap_or("T".to_string()));
new_snippet.push_str(
&self.span_to_snippet(span).unwrap_or_else(|_| "T".to_string()));
new_snippet.push('>');
return Some((sugg_span, new_snippet));