Skip to main content

with

Function with 

Source
pub const fn with<T, F: Fn() -> T + Clone>(generate: F) -> With<F>
Expand description

Creates a generator from a closure that produces a value.

This generator assumes that the closure always returns the same value; if this assumption is violated, checking and shrinking may have unexpected behaviors.

ยงExamples

struct MyStruct(i32);

// A generator that always produces `MyStruct(42)`.
let generator = with(|| MyStruct(42));