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
I have a use-case where I need to generate unique identifiers as part of an implementation of Arbitrary. For example, given fn test_foo(foo_one: Foo, foo_two: Foo), foo_one and foo_two must have different identifiers. I am currently using LazyJust::new(|| Uuid::new_v4().to_string()) to ensure uniqueness. I cannot use Just because Proptest will clone the "unique" identifier, thereby making it non-unique. I cannot use standard Proptest generators because Proptest could generate non-unique values or shrink values into being non-unique. The documentation for LazyJust states "It is important that the function used be pure.". My current use of LazyJust is explicitly not pure, but I cannot find a better way to create a unique identifier for an arbitrary value of a type.
So, what are the consequences of using an impure function for LazyJust? Will shrinking still work, with the understanding that identifiers changing is acceptable? And, if Proptest works with an impure function for LazyJust, perhaps the documentation should be more specific?
The text was updated successfully, but these errors were encountered:
I have a use-case where I need to generate unique identifiers as part of an implementation of
Arbitrary
. For example, givenfn test_foo(foo_one: Foo, foo_two: Foo)
,foo_one
andfoo_two
must have different identifiers. I am currently usingLazyJust::new(|| Uuid::new_v4().to_string())
to ensure uniqueness. I cannot useJust
because Proptest will clone the "unique" identifier, thereby making it non-unique. I cannot use standard Proptest generators because Proptest could generate non-unique values or shrink values into being non-unique. The documentation forLazyJust
states "It is important that the function used be pure.". My current use ofLazyJust
is explicitly not pure, but I cannot find a better way to create a unique identifier for an arbitrary value of a type.So, what are the consequences of using an impure function for
LazyJust
? Will shrinking still work, with the understanding that identifiers changing is acceptable? And, if Proptest works with an impure function forLazyJust
, perhaps the documentation should be more specific?The text was updated successfully, but these errors were encountered: