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
When writing required manual Arbitrary implementations, one of the more painful elements is writing the size_hint() code, because it's a lot of arbitrary::size_hint::* function calls that must mirror the arbitrary() code. If size_hint() used a custom struct type instead of a tuple, this code could be made much more concise and legible using operators and method calls. For example, this size_hint method for one required and one possibly-required field,
(The original code could become shorter with some uses, but the use is itself additional boilerplate to write, particularly since it needs to be placed inside a #[cfg(feature = "arbitrary")] if there is one.)
As written, this is, of course, a breaking change of type, so it would require an arbitrary 2.0, and this isn’t worth that. I only wish to present this idea for consideration in case breaking changes are needed for other reasons.
The text was updated successfully, but these errors were encountered:
When writing required manual
Arbitrary
implementations, one of the more painful elements is writing thesize_hint()
code, because it's a lot ofarbitrary::size_hint::*
function calls that must mirror thearbitrary()
code. Ifsize_hint()
used a custom struct type instead of a tuple, this code could be made much more concise and legible using operators and method calls. For example, thissize_hint
method for one required and one possibly-required field,could become something like
(The original code could become shorter with some
use
s, but theuse
is itself additional boilerplate to write, particularly since it needs to be placed inside a#[cfg(feature = "arbitrary")]
if there is one.)As written, this is, of course, a breaking change of type, so it would require an
arbitrary
2.0, and this isn’t worth that. I only wish to present this idea for consideration in case breaking changes are needed for other reasons.The text was updated successfully, but these errors were encountered: