use std::thread;
use std::time::Duration;

fn generate_workout(intensity: u32, random_number: u32) {
    // ANCHOR: here
    let expensive_closure = |num: u32| -> u32 {
        println!("powolne obliczanie...");
        thread::sleep(Duration::from_secs(2));
        num
    };
    // ANCHOR_END: here

    if intensity < 25 {
        println!("Dzi zrób {} pšpek!", expensive_closure(intensity));
        println!("Następnie {} przysiadów!", expensive_closure(intensity));
    } else {
        if random_number == 3 {
            println!("Dzi zrób sobie przerwę! Pamiętaj o nawodnieniu!");
        } else {
            println!(
                "Dzi pobiegaj {} minut!",
                expensive_closure(intensity)
            );
        }
    }
}

fn main() {
    let simulated_user_specified_value = 10;
    let simulated_random_number = 7;

    generate_workout(simulated_user_specified_value, simulated_random_number);
}
