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

Improve DeserializeSeed documentation #1088

Open
tomasol opened this issue Dec 7, 2023 · 0 comments
Open

Improve DeserializeSeed documentation #1088

tomasol opened this issue Dec 7, 2023 · 0 comments

Comments

@tomasol
Copy link

tomasol commented Dec 7, 2023

The DeserializeSeed contains an example without a clear way to call it. The last two lines should be surrounded by fn example.., but unless one clicks on the source, those lines will not be shown.
I would like to propose removing the leading '#' characters or perhaps changing the usage to the following:

    #[test]
    fn deserialize_seed() {
        let input = "[1, 2]";
        let mut vec: Vec<u64> = Vec::new();
        let mut deserializer = serde_json::Deserializer::from_str(input);
        ExtendVec(&mut vec).deserialize(&mut deserializer).unwrap();
        assert_eq!(vec![1, 2], vec);
    }

    #[test]
    fn visitor_deserialize_seed() {
        let input = "[[1], [2]]";
        let mut deserializer = serde_json::Deserializer::from_str(input);
        let visitor = FlattenedVecVisitor::<u64>(PhantomData);
        let vec: Vec<u64> = deserializer.deserialize_seq(visitor).unwrap();
        assert_eq!(vec![1, 2], vec);
    }
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

1 participant