Nadrieril / dhall-rust

Maintainable configuration files, for Rust users
Other
303 stars 27 forks source link

Derive: support records in Union Types #219

Closed stuebinm closed 3 years ago

stuebinm commented 3 years ago

This adds support for records in variants of union types to the derive StaticType macro, e.g:

#[derive(Deserialize, Serialize, StaticType)]
enum IntRange {
   Bounded {min: i64, max:  i64},
   LowerThan (i64),
   HigherThan (i64),
   Unbounded
}

will result in the following Dhall type:

< Bounded: { max : Integer, min : Integer } | HigherThan: Integer | LowerThan: Integer | Unbounded >

which can then be used to more conveniently read in nested dhall data.

Nadrieril commented 3 years ago

This is cool, thanks for taking the time! Could you add a test that this works as expected in serde_dhall/tests/traits.rs ?

Nadrieril commented 3 years ago

Perfect, thanks!