fn main() {
let _one = None.unwrap_or("one".to_string());
let _two = None.unwrap_or_else(|| "two".to_string());
}
Any particular reason why people should prefer unwrap_or_else
over unwrap_or
?
I have seen comments that unwrap_or
is eager (this as an example). Does that mean the values in unwrap_or
are always evaluated before program execution? And the FnOnce
values in unwrap_or_else
is called only when the program execute up to that line?