Closed clarfonthey closed 3 years ago
PR's are welcome for this.
What would be the ideal implementation here? Using the String
implementation with a null-character or random non-null bytes terminated by a null character? Or some combination of the two?
For example, based on a random variable, either add a valid UTF-8 character to the string or a random non-null byte. Finally, end the string with '\0'
.
Yeah, I think we probably want a mix. I believe the Arbitrary
impl for String
has some smarts to it, and it would be nice to reuse that. While perhaps not optimal, I think one possible implementation of this would be:
Vec<u8>::arbitrary()
and strip all NUL bytes from the result (or replace them with random non-NUL bytes).String::arbitrary()
and strip all NUL bytes from the result (or replace them with random non-NUL UTF-8 encoded Unicode scalar values).
Would be nice to have.
String
's impl isn't quite the same.