fn record_all_rounds<'a>(
	calls: &'a [Number],
	boards: &'a [Board],
) -> impl Iterator<Item = Turn<'a>> {
	calls.iter().enumerate().scan(
		(boards.iter().collect(), BTreeSet::new()),
		|(remaining_boards, seen_calls): &mut (HashSet<&Board>, BTreeSet<Number>), (idx, &call)| {
			seen_calls.insert(call);

			let mut winners: Vec<&'a Board> = vec![];

			for &board in remaining_boards.iter() {
				if board.numbers().intersection(seen_calls).count() < 5 {
					continue;
				} else if let Some(_winning_move) = board.find_winning_move(seen_calls) {
					winners.push(board);
				}
			}

			for &board in winners.iter() {
				remaining_boards.remove(board);
			}

			let calls_so_far: &'a [Number] = &calls[0..=idx];

			Some(Turn {
				call,
				winners,
				calls_so_far,
			})
		},
	)
}
/// From starting conditions, produces an iterator over all of the 'turns'.
///
/// (A 'turn' consists of information about what happens when you call out a number. Some of the
/// boards are winners, and the remaining boards have some number of their spaces filled by the
/// calls you have made so far.)
From starting conditions, produces an iterator over all of the 'turns'.
(A 'turn' consists of information about what happens when you call out a number. Some of the
boards are winners, and the remaining boards have some number of their spaces filled by the
calls you have made so far.)
From starting conditions produces an iterator over all of the ' turns ' . ( A ' turn ' consists of information about what happens when you call out a number . Some of the boards are winners and the remaining boards have some number of their spaces filled by the calls you have made so far . )
fn record_all_rounds<'a>(
	calls: &'a [Number],
	boards: &'a [Board],
) -> impl Iterator<Item = Turn<'a>> {
	calls.iter().enumerate().scan(
		(boards.iter().collect(), BTreeSet::new()),
		|(remaining_boards, seen_calls): &mut (HashSet<&Board>, BTreeSet<Number>), (idx, &call)| {
			seen_calls.insert(call);
			let mut winners: Vec<&'a Board> = vec![];
			for &board in remaining_boards.iter() {
				if board.numbers().intersection(seen_calls).count() < 5 {
					continue;
				} else if let Some(_winning_move) = board.find_winning_move(seen_calls) {
					winners.push(board);
				}
			}
			for &board in winners.iter() {
				remaining_boards.remove(board);
			}
			let calls_so_far: &'a [Number] = &calls[0..=idx];
			Some(Turn {
				call,
				winners,
				calls_so_far,
			})
		},
	)
}
fn record_all_rounds < ' a > ( calls : & ' a [ Number ] , boards : & ' a [ Board ] , ) -> impl Iterator < Item = Turn < ' a > > { calls . iter ( ) . enumerate ( ) . scan ( ( boards . iter ( ) . collect ( ) , BTreeSet :: new ( ) ) , | ( remaining_boards , seen_calls ) : & mut ( HashSet < & Board > , BTreeSet < Number > ) , ( idx , & call ) | { seen_calls . insert ( call ) ; let mut winners : Vec < & ' a Board > = vec ! [ ] ; for & board in remaining_boards . iter ( ) { if board . numbers ( ) . intersection ( seen_calls ) . count ( ) < 5 { continue ; } else if let Some ( _winning_move ) = board . find_winning_move ( seen_calls ) { winners . push ( board ) ; } } for & board in winners . iter ( ) { remaining_boards . remove ( board ) ; } let calls_so_far : & ' a [ Number ] = & calls [ 0 ..= idx ] ; Some ( Turn { call , winners , calls_so_far , } ) } , ) }
From starting conditions, produces an iterator over all of the 'turns'.
From starting conditions produces an iterator over all of the ' turns ' .
calls
&'a [Number]
boards
&'a [Board]
calls
&'a [Number]
boards
&'a [Board]