You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The time crate should upgrade the quickcheck dependency to 1.0 prior to time's 0.3 release. The API is largely similar, but there are some changes. Notably, it is no longer possible (for the time, see BurntSushi/quickcheck#267) to generate a value within a given range. This can be worked around with the following function. It has some limitations with regard to overflow within the type, but I don't believe that should be an issue for any values used in the time crate.
fnarbitrary_between<T>(g:&mutGen,min:T,max:T) -> TwhereT:PartialOrd
+ AddAssign
+ Add<Output = T>
+ Sub<Output = T>
+ Rem<Output = T>
+ Arbitrary
+ Copy,{#[allow(clippy::eq_op)]let zero = min - min;let range = max - min;letmut within_range = T::arbitrary(g) % range;if within_range < zero {
within_range += range;}
within_range + min
}
One thing I noticed in the documentation that I didn't before (I'm not sure if it was present or not and can't be bothered to check) is that the Gen::size() method does not need to be used, as all types in the time crate have a constant size; the example used as a use case is Vec, which most certainly does not. As such, the entire foo_respects_generator_size and test_generator_size! bit can be dropped, I believe.
This should likely be done in coordination with #299, though it's not strictly necessary. That change by itself will be nearly trivial.
cc @emlun if you're interested with your macro magic. No big deal if not.
The text was updated successfully, but these errors were encountered:
The time crate should upgrade the quickcheck dependency to 1.0 prior to time's 0.3 release. The API is largely similar, but there are some changes. Notably, it is no longer possible (for the time, see BurntSushi/quickcheck#267) to generate a value within a given range. This can be worked around with the following function. It has some limitations with regard to overflow within the type, but I don't believe that should be an issue for any values used in the time crate.
One thing I noticed in the documentation that I didn't before (I'm not sure if it was present or not and can't be bothered to check) is that the
Gen::size()
method does not need to be used, as all types in the time crate have a constant size; the example used as a use case isVec
, which most certainly does not. As such, the entirefoo_respects_generator_size
andtest_generator_size!
bit can be dropped, I believe.This should likely be done in coordination with #299, though it's not strictly necessary. That change by itself will be nearly trivial.
cc @emlun if you're interested with your macro magic. No big deal if not.
The text was updated successfully, but these errors were encountered: