diff --git a/book/src/proptest/state-machine.md b/book/src/proptest/state-machine.md index c69a0f05..1806d6d5 100644 --- a/book/src/proptest/state-machine.md +++ b/book/src/proptest/state-machine.md @@ -58,7 +58,7 @@ You also have to implement three associated functions: fn transitions(state: &Self::State) -> BoxedStrategy ``` - Most of the time, you'll use `prop_oneof!` here. If a transition takes some input parameters, you can generate those with a `Strategy` and `.prop_map` it to the `Transition` variant. In more complex state machines, the set of valid transitions may depend on the current state. To that end, you can use the `state` argument, possibly combined with `prop::sample::select` function that allows you to create a strategy that selects a random value from an array or an array-like collection (be careful not to call `select` on an empty array as that will make it fail in a somewhat obscure way). For example, if you want to remove one of the existing keys from a hash map, you can select one of the keys from the current state and map it into a transition. Note that when you do something like this, you'll also need to override the `fn preconditions`, which are explained in more detail below. + Most of the time, you'll use `prop_oneof!` here. If a transition takes some input parameters, you can generate those with a `Strategy` and `.prop_map` it to the `Transition` variant. In more complex state machines, the set of valid transitions may depend on the current state. To that end, you can use the `state` argument, possibly combined with `proptest::sample::select` function that allows you to create a strategy that selects a random value from an array or an array-like collection (be careful not to call `select` on an empty array as that will make it fail in a somewhat obscure way). For example, if you want to remove one of the existing keys from a hash map, you can select one of the keys from the current state and map it into a transition. Note that when you do something like this, you'll also need to override the `fn preconditions`, which are explained in more detail below. - To apply the given transition on the reference state: