rust(lint): don't use unwrap_or for function calls

Calling a function in unwrap_or causes that function to always
be called even when not needed. Instead use unwrap_or_else with
a closure which will only be called when needed.
pull/6304/head
Jason Ish 5 years ago committed by Victor Julien
parent 602bb05e75
commit 5bf5de3350

@ -2149,7 +2149,7 @@ mod tests {
.zip(expected_uuid)
.map(|(x, y)| x.cmp(y))
.find(|&ord| ord != cmp::Ordering::Equal)
.unwrap_or(bind_uuid.len().cmp(&expected_uuid.len()))
.unwrap_or_else(|| bind_uuid.len().cmp(&expected_uuid.len()))
);
}
}

@ -582,7 +582,7 @@ pub fn parse_smb_create_andx_request_record<'a>(i: &'a[u8], r: &SmbRecord)
>> (SmbRequestCreateAndXRecord {
disposition: disposition,
create_options: create_options,
file_name: file_name.unwrap_or(Vec::new()),
file_name: file_name.unwrap_or_default(),
}))
}

Loading…
Cancel
Save