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:

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) -> Self

Wrap the given T in Fuse.

impl<T: ValueTree> Fuse<T>

fn may_simplify(&self) -> bool

Return 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() returned true.
  • complicate() has been called more recently than simplify() and the last call returned true.
fn disallow_simplify(&mut self)

Disallow any further calls to simplify() until a call to complicate() returns true.

fn may_complicate(&self) -> bool

Return whether a call to complicate() may be productive.

Formally, this is true if one of the following holds:

  • The most recent call to complicate() returned true.
  • simplify() has been called more recently than complicate() and the last call returned true.
fn disallow_complicate(&mut self)

Disallow any further calls to complicate() until a call to simplify() returns true.

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::Value
fn simplify(&mut self) -> bool
fn 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) -> T

Returns 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) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Fuse<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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