-
Notifications
You must be signed in to change notification settings - Fork 426
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
Implement HashMap support the same way as Vec (PR #1070) #1071
Comments
@rimutaka as an output type |
@rimutaka
I'm unsure what implications we will have. At first glance this seems to be OK for output, as with usual
I think error, as we do for arrays. If the user uses |
@ilslv , @tyranron , thanks for your prompt replies! You raised some good points.
println!("{:?}", serde_json::from_str::<HashSet<i32>>("[1,2,3,3,3]").unwrap()); prints It seems ignoring duplicates is the default with HashSets. I am not opposed to an error.
Let me investigate a bit more before taking it any further. |
Yup, from the server side. I wonder if it may have some implications on a client side.
Well, on the schema level
I'm unsure about duplicates, despite But It seems reasonable that library users may want It's hard to say for sure which case is more common. But I'd better go with strict defaults. We still may provide a transparent wrapper for a different behaviour: #[derive(Clone, Debug, Deref, DerefMut, From, Into, RefCast)]
#[transparent]
struct DedupHashSet<T>(HashSet<T>); and using it
will allow to use |
I have a struct where some members are Vec and some are HashSet. They both should convert to/from a GraphQL list.
There is a built-in support for Vec, but not for HashSet. I would think that adding HashSet support would make life easier in cases like this.
I copied the
impl
code forVec
to enableHashMap
support in PR #1070. So far it worked fine.If the idea is sound, would you consider that PR?
I will need to add input support, tests and see if docs need updating before it is ready. Just wanted to check with the maintainers (@tyranron , @ilslv, @LegNeato ?) if I'm on the right track here.
The text was updated successfully, but these errors were encountered: