amazon-ion / ion-schema-rust

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

Create constraint macros that are more ergonomic and concise #195

Open popematt opened 1 year ago

popematt commented 1 year ago

As a library TODO (if/when we finish the versioning-via-generics refactoring), we should look at making constraint macros that coalesce failure modes and elide all of the .into()s that are currently required at the call site, turning this:

valid_values(
  vec![
    2.into(), 
    ion_rs::Decimal::new(35, -1).into(),
    5e7.into(),
    "hello".to_owned().into(),
    Symbol::from("hi").into(), 
    NumberRange::new_inclusive(2.into(), 3.into()).unwrap().into()
  ]
)

into something more like:

valid_values! [
  2,
  Decimal::new(35, -1), 
  5e7,
  "hello",
  Symbol::from("hi")
  inclusive_number_range! [2, 3]
],

_Originally posted by @zslayton in https://github.com/amazon-ion/ion-schema-rust/pull/190#discussion_r1249551892_