Struct Fuse
#[must_use = "strategies do nothing unless used"]
pub struct Fuse<T> { /* private fields */ }
Adaptor for Strategy and ValueTree which guards simplify() and
complicate() to avoid contract violations.
This can be used as an intermediate when the caller would otherwise need
its own separate state tracking, or as a workaround for a broken
ValueTree implementation.
This wrapper specifically has the following effects:
-
Calling
complicate()beforesimplify()was ever called does nothing and returnsfalse. -
Calling
simplify()after it has returnedfalseand no calls tocomplicate()returnedtruedoes nothing and returnsfalse. -
Calling
complicate()after it has returnedfalseand no calls tosimplify()returnedtruedoes nothing and returnsfalse.
There is also limited functionality to alter the internal state to assist in its usage as a state tracker.
Wrapping a Strategy in Fuse simply causes its ValueTree to also be
wrapped in Fuse.
While this is similar to std::iter::Fuse, it is not exposed as a method
on Strategy since the vast majority of proptest should never need this
functionality; it mainly concerns implementors of strategies.
Implementations
impl<T> Fuse<T>
fn new(inner: T) -> SelfWrap the given
TinFuse.
impl<T: ValueTree> Fuse<T>
fn may_simplify(&self) -> boolReturn whether a call to
simplify()may be productive.Formally, this is true if one of the following holds:
simplify()has never been called.- The most recent call to
simplify()returnedtrue. complicate()has been called more recently thansimplify()and the last call returnedtrue.
fn disallow_simplify(&mut self)Disallow any further calls to
simplify()until a call tocomplicate()returnstrue.fn may_complicate(&self) -> boolReturn whether a call to
complicate()may be productive.Formally, this is true if one of the following holds:
- The most recent call to
complicate()returnedtrue. simplify()has been called more recently thancomplicate()and the last call returnedtrue.
- The most recent call to
fn disallow_complicate(&mut self)Disallow any further calls to
complicate()until a call tosimplify()returnstrue.fn freeze(&mut self)Prevent any further shrinking operations from occurring.
Trait Implementations
impl<T: Clone> Clone for Fuse<T>
fn clone(&self) -> Self
impl<T: Copy> Copy for Fuse<T>
impl<T: Debug> Debug for Fuse<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: Strategy> Strategy for Fuse<T>
type Tree = Fuse<<T as Strategy>::Tree>;type Value = <T as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<T: ValueTree> ValueTree for Fuse<T>
type Value = <T as ValueTree>::Value;fn current(&self) -> T::Valuefn simplify(&mut self) -> boolfn complicate(&mut self) -> bool
Auto Trait Implementations
impl<T> Freeze for Fuse<T>
where
T: Freeze,
impl<T> RefUnwindSafe for Fuse<T>
where
T: RefUnwindSafe,
impl<T> Send for Fuse<T>
where
T: Send,
impl<T> Sync for Fuse<T>
where
T: Sync,
impl<T> Unpin for Fuse<T>
where
T: Unpin,
impl<T> UnsafeUnpin for Fuse<T>
where
T: UnsafeUnpin,
impl<T> UnwindSafe for Fuse<T>
where
T: UnwindSafe,
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Fuse<T>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Fuse<T>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for Fuse<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Fuse<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Fuse<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Fuse<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Fuse<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Read<Exclusive, BecauseExclusive> for Fuse<T>
where
T: ?Sized,
impl<T> ToOwned for Fuse<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Fuse<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Fuse<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Fuse<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip<V> for Fuse<T>
where
V: MultiLane<T>,
fn vzip(self) -> V