Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ pub fn single_shrinker<A: 'static>(value: A) -> Box<dyn Iterator<Item = A>> {
///
/// As of now, all types that implement `Arbitrary` must also implement
/// `Clone`. (I'm not sure if this is a permanent restriction.)
///
/// They must also be sendable and static since every test is run in its own
/// thread using `thread::Builder::spawn`, which requires the `Send + 'static`
/// bounds.
pub trait Arbitrary: Clone + Send + 'static {
pub trait Arbitrary: Clone + 'static {
fn arbitrary<G: Gen>(g: &mut G) -> Self;

fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
Expand Down Expand Up @@ -401,7 +397,7 @@ impl<K: Arbitrary + Ord, V: Arbitrary> Arbitrary for BTreeMap<K, V> {
impl<
K: Arbitrary + Eq + Hash,
V: Arbitrary,
S: BuildHasher + Default + Clone + Send + 'static,
S: BuildHasher + Default + Clone + 'static,
> Arbitrary for HashMap<K, V, S>
{
fn arbitrary<G: Gen>(g: &mut G) -> Self {
Expand Down Expand Up @@ -441,10 +437,8 @@ impl<T: Arbitrary + Ord> Arbitrary for BinaryHeap<T> {
}
}

impl<
T: Arbitrary + Eq + Hash,
S: BuildHasher + Default + Clone + Send + 'static,
> Arbitrary for HashSet<T, S>
impl<T: Arbitrary + Eq + Hash, S: BuildHasher + Default + Clone + 'static>
Arbitrary for HashSet<T, S>
{
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let vec: Vec<T> = Arbitrary::arbitrary(g);
Expand Down
12 changes: 6 additions & 6 deletions src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ impl TestResult {
pub fn must_fail<T, F>(f: F) -> TestResult
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send + 'static,
F: 'static,
T: 'static,
{
let f = panic::AssertUnwindSafe(f);
TestResult::from_bool(panic::catch_unwind(f).is_err())
Expand Down Expand Up @@ -305,7 +305,7 @@ impl TestResult {
/// and potentially shrink those arguments if they produce a failure.
///
/// It's unlikely that you'll have to implement this trait yourself.
pub trait Testable: Send + 'static {
pub trait Testable: 'static {
fn result<G: Gen>(&self, _: &mut G) -> TestResult;
}

Expand All @@ -330,7 +330,7 @@ impl Testable for TestResult {
impl<A, E> Testable for Result<A, E>
where
A: Testable,
E: Debug + Send + 'static,
E: Debug + 'static,
{
fn result<G: Gen>(&self, g: &mut G) -> TestResult {
match *self {
Expand Down Expand Up @@ -409,8 +409,8 @@ testable_fn!(A, B, C, D, E, F, G, H);
fn safe<T, F>(fun: F) -> Result<T, String>
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send + 'static,
F: 'static,
T: 'static,
{
panic::catch_unwind(panic::AssertUnwindSafe(fun)).map_err(|any_err| {
// Extract common types of panic payload:
Expand Down