Struct Height

A type to ensure that height and other integer values aren't mixed

struct Height ;

Fields

NameTypeDescription
value ulong

Methods

NameDescription
fromString (str) Support for Vibe.d deserialization
opBinary (offset) Allow to offset an height by a fixed number
opBinaryAssign (offset) Allow to offset an height by a fixed number
opUnary () Prevent needing to cast when using unary post plus operator
toString () Support for Vibe.d serialization to JSON

Example

import vibe.data.json;

const h = Height(1000);
const(char)[] str_h = "1000";

assert(h.toString() == str_h);
assert(h.fromString(str_h) == h);
assert(h.serializeToJsonString() == "\"1000\"");
auto x = Height(10);
assert(x++ == 10);
assert(x == 11);

auto y = x + 1;
assert(y == 12);

y += 5;
assert(y == 17);