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

Implement `ToRangeBoundaryValue` trait #48

Closed desaikd closed 2 years ago

desaikd commented 2 years ago

We should consider making a ToRangeBoundaryValue trait that we can implement for i32, i64, f64, Decimal, Timestamp, etc. If we consolidate to a single range method (as described in another comment), we could then invoke it like this:

Range::range(5, 10)
Range::range(1.2, 5.9)
Range::range(Decimal::new(5, 0), Decimal::new(11, 0))

This short form would default to Inclusive bounds. Someone who wanted exclusive boundaries could use the more verbose syntax.

_Originally posted by @zslayton in https://github.com/amzn/ion-schema-rust/pull/45#discussion_r749556670_

desaikd commented 2 years ago

This has already been included by generic range implementation(#95) as below: https://github.com/amzn/ion-schema-rust/blob/42a6f9482af837a57af7a318b15bf9994eaf1b65/src/isl/isl_range.rs#L641-L645