-
Notifications
You must be signed in to change notification settings - Fork 29
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
More to_type functions for Value #99
Comments
In my experience, if you want to go that far, you'll have to manage the complexity inside these convenience helper methods, so you'll need three families of them:
I'm not against this change, especially since it is relatively simple, but I believe the ultimate solution should be a serializer/deserializer trait to just go around the Bin hash map and directly pass structs to methods and get them back with the values assigned. |
the
For the deserializer definitely. I'm not sure what a serializer could look like without performance impact and a load of boilerplate for the user like in #97. |
The point of Regarding the serializer, I've been thinking of a macro that would take care of it automatically by implementing a variation of the trait in #97. You wouldn't have to write code, just mark your struct with the macro, same as you do with Clone/Debug/etc. |
I have implemented the TryFrom trait mentioned in #124 and I think that is the elegant way to handle this issue. What's your opinion? |
Looks like the easiest solution for this. I'd say this is done then. |
Value currently only has a to_string method.
As far as i understand thats more meant as some sort of "debug" function to just print whats inside the value.
I guess it might be a good idea to add more functions for other Data Types.
This functions could return a Result with the Value or an Error if the Type is not correct.
Currently the only way to do this is pattern matching. But if you need to match for example 10 bins, that becomes very ugly.
The type of the bins is probably known in most applications anyways. A strictly typed language like rust more or less forces you to know when you write it.
Im thinking about something like
In the end it will not change how this fields are matched, but it reduces the boilerplate and nesting required to parse the record into a struct for example. In that case, you probably want to throw an Error if a bin type does not match the struct type.
Any thoughts on this?
The text was updated successfully, but these errors were encountered: