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

feat: Generic Precision #234

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TurtIeSocks
Copy link

@TurtIeSocks TurtIeSocks commented Oct 26, 2023

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

Following up from my post almost a year ago in #59 , I finally got around to finishing this up!

This adds support for the generic CoordFloat trait to all structs provided by this crate. I've tested this locally in my OSS project and the only inconsistency I noticed was serializing with the json! macro from serde_json always resulted in f64 precision, but I wasn't sure if that is something that can be corrected in this crate. When returning the data and letting Actix serialize it with something like HttpResponse::Ok().json(feature), it respected the intended precision.

Notes for the maintainers to review:

  • I'm still pretty new when it comes to Rust so there may be a lot of things that could be simplified, particularly when it comes to the Error/Result generics that were added in to account for the one error that involves generic precision.
  • Going off of the generic args I had to add to some of the tests/examples, I think I may still need to add some more f64 defaults to make this a non-breaking change.
  • I noticed a mix of how traits are added to generics, both using the : and where syntax, I tried to follow the code style as it was presented but let me know if anything should be adjusted.

Resolves #59

@TurtIeSocks
Copy link
Author

Apologies for the tag @michaelkirk, but any feedback for this PR :) thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use generic type for precision
1 participant