Skip to content

Commit

Permalink
Add Config::with_failure_persistence
Browse files Browse the repository at this point in the history
A convenience constructor making use of a generic parameter
over FailurePersistence impls and hiding the Some(Box::new(...)) cruft.
  • Loading branch information
mzabaluev authored and matthew-russo committed Sep 22, 2024
1 parent 77b2f83 commit 80ede61
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions proptest/src/test_runner/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,32 @@ impl Config {
result
}

/// Constructs a `Config` only differing from the `default()` in the
/// failure_persistence member.
///
/// This is simply a more concise alternative to using field-record update
/// syntax:
///
/// ```
/// # use proptest::test_runner::{Config, FileFailurePersistence};
/// assert_eq!(
/// Config::with_failure_persistence(FileFailurePersistence::WithSource("regressions")),
/// Config {
/// failure_persistence: Some(Box::new(FileFailurePersistence::WithSource("regressions"))),
/// .. Config::default()
/// }
/// );
/// ```
pub fn with_failure_persistence<T>(failure_persistence: T) -> Self
where
T: FailurePersistence + 'static,
{
Self {
failure_persistence: Some(Box::new(failure_persistence)),
..Default::default()
}
}

/// Return whether this configuration implies forking.
///
/// This method exists even if the "fork" feature is disabled, in which
Expand Down

0 comments on commit 80ede61

Please sign in to comment.