Struct Fuse
pub struct Fuse<T> {
    inner: T,
    may_simplify: bool,
    may_complicate: bool,
}Expand description
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.
Fields§
§inner: T§may_simplify: bool§may_complicate: boolImplementations§
§impl<T> Fuse<T>where
    T: ValueTree,
 
impl<T> Fuse<T>where
    T: ValueTree,
pub fn may_simplify(&self) -> bool
pub 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()returnedtrue. complicate()has been called more recently thansimplify()and the last call returnedtrue.
pub fn disallow_simplify(&mut self)
pub fn disallow_simplify(&mut self)
Disallow any further calls to simplify() until a call to
complicate() returns true.
pub fn may_complicate(&self) -> bool
pub 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()returnedtrue. simplify()has been called more recently thancomplicate()and the last call returnedtrue.
pub fn disallow_complicate(&mut self)
pub fn disallow_complicate(&mut self)
Disallow any further calls to complicate() until a call to
simplify() returns true.
pub fn freeze(&mut self)
pub fn freeze(&mut self)
Prevent any further shrinking operations from occurring.
Trait Implementations§
§impl<T> Strategy for Fuse<T>where
    T: Strategy,
 
impl<T> Strategy for Fuse<T>where
    T: Strategy,
§type Value = <T as Strategy>::Value
 
type Value = <T as Strategy>::Value
§fn new_tree(
    &self,
    runner: &mut TestRunner,
) -> Result<<Fuse<T> as Strategy>::Tree, Reason>
 
fn new_tree( &self, runner: &mut TestRunner, ) -> Result<<Fuse<T> as Strategy>::Tree, Reason>
§fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
 
fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
fun. Read more§fn prop_map_into<O>(self) -> MapInto<Self, O>
 
fn prop_map_into<O>(self) -> MapInto<Self, O>
§fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
 
fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
fun, which is additionally given a random number generator. Read more§fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
 
fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
§fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
 
fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
§fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
 
fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
prop_ind_flat_map(), but produces 2-tuples with the input
generated from self in slot 0 and the derived strategy in slot 1. Read more§fn prop_filter<R, F>(self, whence: R, fun: F) -> Filter<Self, F>
 
fn prop_filter<R, F>(self, whence: R, fun: F) -> Filter<Self, F>
fun. Read more§fn prop_filter_map<F, O>(
    self,
    whence: impl Into<Reason>,
    fun: F,
) -> FilterMap<Self, F>
 
fn prop_filter_map<F, O>( self, whence: impl Into<Reason>, fun: F, ) -> FilterMap<Self, F>
fun
returns Some(value) and rejects those where fun returns None. Read more§fn prop_union(self, other: Self) -> Union<Self>where
    Self: Sized,
 
fn prop_union(self, other: Self) -> Union<Self>where
    Self: Sized,
§fn prop_recursive<R, F>(
    self,
    depth: u32,
    desired_size: u32,
    expected_branch_size: u32,
    recurse: F,
) -> Recursive<Self::Value, F>
 
fn prop_recursive<R, F>( self, depth: u32, desired_size: u32, expected_branch_size: u32, recurse: F, ) -> Recursive<Self::Value, F>
self items as leaves. Read more§fn prop_shuffle(self) -> Shuffle<Self>
 
fn prop_shuffle(self) -> Shuffle<Self>
§fn boxed(self) -> BoxedStrategy<Self::Value>where
    Self: Sized + 'static,
 
fn boxed(self) -> BoxedStrategy<Self::Value>where
    Self: Sized + 'static,
Strategy so it can be passed around as a
simple trait object. Read more§fn sboxed(self) -> SBoxedStrategy<Self::Value>
 
fn sboxed(self) -> SBoxedStrategy<Self::Value>
Strategy so it can be passed around as a
simple trait object. Read more§impl<T> ValueTree for Fuse<T>where
    T: ValueTree,
 
impl<T> ValueTree for Fuse<T>where
    T: ValueTree,
§fn simplify(&mut self) -> bool
 
fn simplify(&mut self) -> bool
§fn complicate(&mut self) -> bool
 
fn complicate(&mut self) -> bool
impl<T> Copy for Fuse<T>where
    T: Copy,
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> UnwindSafe for Fuse<T>where
    T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
 
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
    C: Color,
 
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
    C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
    C: Color,
 
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
    C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
 
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
 
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
 
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
 
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
 
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
 
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
 
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
 
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
 
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
 
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
 
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
 
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
 
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
 
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
 
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
 
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
 
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
 
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
 
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
 
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
 
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
 
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
 
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
    Color: DynColor,
 
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
    Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
    Color: DynColor,
 
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
    Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
    &self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
 
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
    &self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
 
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
 
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
 
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<Response, Error> ResponseResult<Response, Error> for Response
 
impl<Response, Error> ResponseResult<Response, Error> for Response
Source§fn into_result(self) -> Result<Response, Error>
 
fn into_result(self) -> Result<Response, Error>
Result that can be sent as a response.