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

Refactor TemporalFields interface and add FieldsKey enum #87

Merged
merged 6 commits into from
Jul 20, 2024

Conversation

nekevss
Copy link
Member

@nekevss nekevss commented Jul 20, 2024

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.

src/fields.rs Outdated
time_zone: None,
}
}
properties: FxHashMap<FieldKey, FieldValue>,
Copy link
Member

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.

Copy link
Member Author

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 😄

@nekevss nekevss marked this pull request as ready for review July 20, 2024 15:14
@nekevss
Copy link
Member Author

nekevss commented Jul 20, 2024

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.

@nekevss nekevss added the C-internal Internal library improvements label Jul 20, 2024
@nekevss nekevss changed the title Refactor TemporalFields to a HashMap vs the static struct. Refactor TemporalFields interface and add FieldsKey enum Jul 20, 2024
Copy link
Member

@jedel1043 jedel1043 left a 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);

@nekevss
Copy link
Member Author

nekevss commented Jul 20, 2024

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.

Copy link
Member

@jedel1043 jedel1043 left a 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

@nekevss nekevss merged commit d4459d0 into main Jul 20, 2024
5 checks passed
@jedel1043 jedel1043 deleted the refactor-temporal-fields branch July 20, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-internal Internal library improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants