Home Holidays Blog About

This is the first blog article

We show you some Rust code.

fn function_a(input: i32) -> Option<i32> {
    Some(input * 2)
}

fn function_b(a: i32, b: i32) -> Option<i32> {
    Some(a + b)
}

fn function_c() -> Option<i32> {
    Some(10)
}

fn main() {
    let input = 5;

    let result = function_a(input)
        .and_then(|a| function_c().map(move |c| (a, c)))
        .and_then(|(a, c)| function_b(a, c));

    match result {
        Some(value) => println!("Result: {}", value),
        None => println!("Error occurred during computation."),
    }
}