var._extractDecimal

private T _extractDecimal(T)() if (_isFDInst!T) const @safe
  • Convert the stored value to type T.
  • Conversion rules:
  • - If the current type is Type.NULL, this returns T.init.
  • - Scalars and strings convert via std.conv.to.
  • - If the current type is Type.ARRAY and T is var[],
  • a copy of the underlying array is returned (each element is a deep
  • copy, so nested containers and native buffers are not aliased). If T
  • is string, this returns the textual representation from toString().
  • - If the current type is Type.OBJECT (map) and T is var[string],
  • an independent copy of the underlying map is returned, with every
  • value deep-copied through the same qualified-copy path as dup. If
  • T is string, this returns the textual representation from
  • toString().
  • - For other combinations, behavior is currently T.init.

    Throws

    VarTypeException if T is one of the datetime types (Date,
  • TimeOfDay, DateTime, SysTime, Duration) and the stored type
  • does not match exactly. Prepare a FixedDecimal extraction target from the stored decimal.

Shared by as and tryAs. Exact-capacity copies are cheap; cross-capacity conversions are checked; fixed-scale targets are produced by checked atScale rescaling, and the contract is final- target representability: wide values rescale in wide capacity first and narrow afterwards. Wide runtime-scale targets widen before any fixed scale applies.

Throws: FixedDecimalException when checked rescaling/narrowing fails.