mirror of
https://github.com/PacktPublishing/Rust-High-Performance.git
synced 2026-01-25 02:34:19 +09:00
23 lines
462 B
Rust
23 lines
462 B
Rust
fn main() {
|
|
let opt = Some(123);
|
|
let non_opt = opt.unwrap_or(some_complex_function());
|
|
|
|
let opt = Some(123);
|
|
let non_opt = opt.unwrap_or_else(some_complex_function);
|
|
|
|
let opt = Some(123);
|
|
let non_opt = opt.unwrap_or_else(|| even_more_complex_function(get_argument()));
|
|
}
|
|
|
|
fn some_complex_function() -> i32 {
|
|
unimplemented!()
|
|
}
|
|
|
|
fn even_more_complex_function(a: i32) -> i32 {
|
|
a
|
|
}
|
|
|
|
fn get_argument() -> i32 {
|
|
unimplemented!()
|
|
}
|