replaced some map_or with map_or_else

This commit is contained in:
klensy 2021-02-24 01:02:05 +03:00
parent 5ff1be197e
commit c75c4a579b
12 changed files with 82 additions and 70 deletions

View file

@ -223,7 +223,7 @@ impl<'a> Parser<'a> {
fn tokens_to_string(tokens: &[TokenType]) -> String {
let mut i = tokens.iter();
// This might be a sign we need a connect method on `Iterator`.
let b = i.next().map_or(String::new(), |t| t.to_string());
let b = i.next().map_or_else(|| String::new(), |t| t.to_string());
i.enumerate().fold(b, |mut b, (i, a)| {
if tokens.len() > 2 && i == tokens.len() - 2 {
b.push_str(", or ");