-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor TemporalFields
interface and add FieldsKey
enum
#87
Conversation
src/fields.rs
Outdated
time_zone: None, | ||
} | ||
} | ||
properties: FxHashMap<FieldKey, FieldValue>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall question. Why do we need to use a hashmap? I would say having a map-like interface for the current struct approach would also work well, with the advantage of being all in the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm, changing the interface might work as well.
I'm not entirely sure how much of a fan I am of the large struct that this switches away from, but it could also primarily be the API for the struct that I'm annoyed by.
I'll play around with it a bit more 😄
Marking as ready for review. I think this is an improvement interface/API wise vs. the old methods. If anyone has suggestions, let me know. |
TemporalFields
to a HashMap
vs the static struct.TemporalFields
interface and add FieldsKey
enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this sounds paradoxical after saying in the last PR that we should reduce our usage of generics, but what do you think about using generics to move the errors to user code?
It would be cool to have something like
fields.set::<Month>(5i32);
Hmmmm, I do sort like the idea. If it makes the API easy to use and the code a tad cleaner / easier to reason through, then I don't see a reason to not try. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I think we can merge this as it is, then discuss the new design on Matrix and create a new PR for the redesign
This refactors the representation to
TemporalFields
. The previous implementation was a bit cumbersome. This is meant to trim down the implementation and, hopefully, make the API a simpler.