Skip to main content

sequence

Function sequence 

Source
pub fn sequence<T: Copy + PartialEq>(
    moves: &[Move<T>],
    scratch: T,
) -> Vec<Move<T>>
Expand description

The moves in an order they can be made in, one at a time.

The result writes exactly the places the input writes, and every one of them ends up holding what the input said it should, except that the scratch may hold anything afterwards. A move from a place to itself is not in the result, because it is nothing to do.

The scratch is written only when a set of moves is a cycle, which is the case no order can answer on its own. Nothing else in the moves may name it, since it is the one place the algorithm is free to destroy.

ยงPanics

Panics if two moves write the same place. That is not a set of parallel moves, it is a question about which of two values a place ends up holding, and the caller has to answer it before asking for an order.