News for hackers. Stuff that matters.
Re:Rust's Poor Composability by NobodyNada on Thursday April 06, 2023 @11:10AM (#35469386)
That's not true: https://play.rust-lang.org/?version=stable&mode=debug&editio...

    let v: Option<Vec<i32>> = (0..5).map(|i| {
        print!("{i} ");
        if i == 3 { None } else { Some(i) }
    }).collect();
    // prints 0 1 2 3
Re:Rust's Poor Composability by remram on Thursday April 06, 2023 @11:15AM (#35469452)
Short-circuit refers to stopping not skipping.
Re:Rust's Poor Composability by fnordpiglet on Thursday April 06, 2023 @12:01PM (#35470312)
I don’t understand. The example you replied to stopped, not skipped.
Re:Rust's Poor Composability by aPoCoMiLogin on Friday April 07, 2023 @09:38AM (#35481437)
that should print 4 and 5 if that was skipping ?
Re:Rust's Poor Composability by remram on Friday April 07, 2023 @12:10PM (#35483220)
Yeah I read too fast.

One of the issues with type inference, this exact same code does different things depending on whether the result is assigned to `Option<Vec<i32>>` or `Vec<Option<i32>>`