nutype icon indicating copy to clipboard operation
nutype copied to clipboard

Integrate with `fake-rs`

Open musjj opened this issue 1 year ago β€’ 2 comments

fake-rs allows you to generate fakers for newtypes:

#[derive(Debug, Dummy)]
struct NewTypeTuple(#[dummy(faker = "1..100")] usize, String);

But of course, it doesn't work with nutype. So it would be nice if it can integrate with it.

musjj avatar Jan 11 '25 16:01 musjj

Nutype already partially supports Arbitrary. I think, it could be possible relatively cheaply implement Fake trait through Arbitrary. On other hand in that case Arbitrary would be mandatory. I need some time to think about it.

greyblake avatar Jan 13 '25 22:01 greyblake

The nice thing about fake-rs is that it can produce somewhat convincing, human-readable values. For example, people names: https://github.com/cksac/fake-rs/blob/4cfcb90782c5a431a1d247823299144da9db9514/fake/src/locales/mod.rs#L14. This is useful when you want to quickly prototype UI for your API, etc.

It looks like that arbitrary is meant for automated, fuzz testing. So I think the usecases are very different here.

musjj avatar Jan 14 '25 10:01 musjj