vibe.d Serialize/Deserialize SumType to/from json

Paul Backus snarwin at gmail.com
Mon Jul 4 13:09:51 UTC 2022


On Monday, 4 July 2022 at 11:35:24 UTC, Antonio wrote:
> (or a way for creating a custom struct "inheriting" SumType 
> with serialization capabilities)?

You can "inherit" from a struct using `alias this`:

```d
struct CustomStruct
{
     SumType!(A, B, C) unwrap;
     alias unwrap this;

     // serialization stuff here
}
```

Documentation: https://dlang.org/spec/class.html#alias-this


More information about the Digitalmars-d-learn mailing list