SHARE
TWEET

Untitled

a guest Oct 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let bools = vec![false,true,true,false,false,true,false,false,true,true,false];
  3.     let result: Vec<_> = bools.iter().scan(0, |n,b| {if *b { *n += 1;} Some(*n)}).collect();
  4.  
  5.     println!("{:?}", result);
  6. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top