import core.time : Duration; class Class { @NonInit float f_; this(float f) { this.f_ = f; } mixin(GenerateInvariants); } (new Class(float.init)).shouldThrow!AssertError;
When <b>any</b> condition check is applied to a nullable field, the test applies to the value, if any, contained in the field. The "null" state of the field is ignored.
import std.typecons : Nullable, nullable; class Class { @NonInit Nullable!float f_; this(Nullable!float f) { this.f_ = f; } mixin(GenerateInvariants); } (new Class(5f.nullable)).f_.isNull.shouldBeFalse; (new Class(Nullable!float())).f_.isNull.shouldBeTrue; (new Class(float.init.nullable)).shouldThrow!AssertError;
When a field is marked with @NonInit, field !is T.init is asserted.