From 52d3a38073aeb6c72d4a82140175b2ebab47cd38 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 22 Sep 2024 13:22:08 -0400 Subject: [PATCH] [proptest-state-machine] Introduce Sequential::new ctor (#506) --- proptest-state-machine/src/strategy.rs | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/proptest-state-machine/src/strategy.rs b/proptest-state-machine/src/strategy.rs index 15abfb44..d13c39c4 100644 --- a/proptest-state-machine/src/strategy.rs +++ b/proptest-state-machine/src/strategy.rs @@ -102,13 +102,13 @@ pub trait ReferenceStateMachine { BoxedStrategy, BoxedStrategy, > { - Sequential { - size: size.into(), - init_state: Self::init_state, - preconditions: Self::preconditions, - transitions: Self::transitions, - next: Self::apply, - } + Sequential::new( + size.into(), + Self::init_state, + Self::preconditions, + Self::transitions, + Self::apply, + ) } } @@ -146,6 +146,26 @@ pub struct Sequential { next: fn(state: State, transition: &Transition) -> State, } +impl + Sequential +{ + pub fn new( + size: SizeRange, + init_state: fn() -> StateStrategy, + preconditions: fn(state: &State, transition: &Transition) -> bool, + transitions: fn(state: &State) -> TransitionStrategy, + next: fn(state: State, transition: &Transition) -> State, + ) -> Self { + Self { + size, + init_state, + preconditions, + transitions, + next, + } + } +} + impl Debug for Sequential {