Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module plus.models.removeme;
- import vibe.data.json;
- import std.datetime;
- struct Person {
- string birthDate;
- string deathDate;
- string retirementDate;
- // custom <struct public Person>
- // end <struct public Person>
- }
- struct Asset {
- string name;
- int quantity = 1;
- double unitValue = 1.0;
- // custom <struct public Asset>
- // end <struct public Asset>
- }
- struct Dossier {
- Person[string] family;
- Asset[string] assets;
- // custom <struct public Dossier>
- // end <struct public Dossier>
- }
- // custom <module public removeme>
- T make(T)(void delegate(ref T t) dg) {
- T result;
- dg(result);
- return result;
- }
- // end <module public removeme>
- static if(1) unittest {
- // custom <unittest removeme>
- import std.stdio;
- auto d = make((ref Dossier _) {
- _.family = [
- "father" : make((ref Person _) {
- _.birthDate = "2001/1/1";
- _.deathDate = "2101/1/1";
- _.retirementDate = "2100/1/1"; }),
- "mother" : make((ref Person _) {
- _.birthDate = "2005/1/1";
- _.deathDate = "2125/1/1";
- _.retirementDate = "2100/1/1"; }),
- ];
- _.assets = [
- "house" : make((ref Asset _) {
- _.name = "Home on the Hill";
- _.unitValue = 120_000; }),
- "car" : make((ref Asset _) {
- _.name = "Dodge Dart";
- _.unitValue = 500; })
- ];
- });
- writeln(d);
- // end <unittest removeme>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement