Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert_de_tokens_error examples for Compact and Readable representation #4

Open
huxi opened this issue Mar 19, 2019 · 1 comment

Comments

@huxi
Copy link

huxi commented Mar 19, 2019

I had a hard time finding out about how to use assert_de_tokens_error in combination with types having both readable and compact representation.

If one simply uses assert_de_tokens_error::<Foo> for a type Foo with both readable and compact representation, the following error message is provided:

Types which have different human-readable and compact representations 
must explicitly mark their test cases with `serde_test::Configure`

This makes sense in general but isn't really that helpful.

It took me way too long to realize that the correct calls to achieve this are assert_de_tokens_error::<Compact<Foo>> and assert_de_tokens_error::<Readable<Foo>>.

This, again, makes sense but isn't that obvious, especially given the original error message.

It would be nice to provide some examples for this use case in the documentation of assert_de_tokens_error.

@dtolnay
Copy link
Member

dtolnay commented Mar 19, 2019

Thanks! I agree this needs much better documentation and probably a better error message.

@dtolnay dtolnay transferred this issue from serde-rs/serde Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants