amazon-ion / ion-schema-rust

Rust implementation of Ion Schema
https://amazon-ion.github.io/ion-schema/sandbox
Apache License 2.0
13 stars 6 forks source link

Refactor Ranges so that they are easier to use #190

Closed popematt closed 1 year ago

popematt commented 1 year ago

Issue #, if available:

N/A

Description of changes:

Current implementation of Range has unnecessary structs/enums that make it confusing to use and maintain. Range was an enum of the possible types of ranges, and was used in places where there should only be one type of range. The Rust-y thing to do would be to rely on generics/monomorphization of RangeImpl. (This is also problem in the Kotlin implementation that was ported over when ion-schema-rust was in its early days.)

In addition, TypedRangeBoundaryValue and RangeBoundaryValue had a lot of redundancy, and RangeBoundaryType models inclusivity/exclusivity, but it's not truly orthogonal with the boundedness/unboundedness (which is modeled in RangeBoundaryValue and TypedRangeBoundaryValue).

Major changes in this PR include:

There's also PR tour notes in the PR diff that call out smaller changes.

Some things that I don't have a strong opinion about and/or want feedback:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

desaikd commented 1 year ago

Overall this is a really nice improvement! Just added few minor comments and related questions.