use core::fmt::Debug; use proptest::{prelude::*, sample::SizeRange}; use crate::{Item, SumTree, Summary}; impl Arbitrary for SumTree where T: Debug + Arbitrary + Item + 'static, T::Summary: Debug + Summary = ()>, { type Parameters = (); type Strategy = BoxedStrategy; fn arbitrary_with((): Self::Parameters) -> Self::Strategy { any::>() .prop_map(|vec| SumTree::from_iter(vec, ())) .boxed() } } /// A strategy for producing a [`SumTree`] with a given size. /// /// Equivalent to [`proptest::collection::vec`]. pub fn sum_tree(values: S, size: impl Into) -> impl Strategy> where T: Debug + Arbitrary + Item + 'static, T::Summary: Debug + Summary = ()>, S: Strategy, { proptest::collection::vec(values, size).prop_map(|vec| SumTree::from_iter(vec, ())) }