3 ms·
That's not true: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=226af340b7c47f3ccf25024049f595f6 https://play.rust-lang.org/?version=st
by NobodyNada 4y ago
That's not true: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=226af340b7c47f3ccf25024049f595f6 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
- remram 4y agoShort-circuit refers to stopping not skipping.
- fnordpiglet 4y agoI don’t understand. The example you replied to stopped, not skipped.
- aPoCoMiLogin 4y agothat should print 4 and 5 if that was skipping ?
- remram 4y agoYeah 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>>`