Both are evaluated during the program’s execution and can be arbitrary values. The difference is that:
- With
unwrap_orthe fallback value is evaluated just beforeunwrap_oris called, and therefore is evaluated whether it’s needed or not (because Rust is an eager language). - With
unwrap_or_elsethe fallback value is evaluated only whenunwrap_or_elsetriggers it (by invoking the function you pass), and therefore is evaluated only if it’s needed.