atilaneves / cerealed

Powerful binary serialisation library for D
BSD 3-Clause "New" or "Revised" License
92 stars 3 forks source link

Custom structs as keys in an associative array are not serialized #1

Closed TyOverby closed 10 years ago

TyOverby commented 10 years ago
module test;

import cerealed;
import std.stdio;

struct Pair {
  string s1;
  int a;
}

void main() {
  auto p = Pair("foo", 5);

  int[Pair] map;
  map[p] = 105;

  auto ser = new Cerealiser();
  ser ~= map;

  auto deser = new Decerealiser(ser.bytes);
  int[Pair] outcu = deser.value!(int[Pair]);
  writeln(outcu);
}

Expected output: [Pair("foo", 5): 105] Actual output : [Pair("", 0): 105]

atilaneves commented 10 years ago

Fixed in the last commit.