Sign
public enum SignHow the sign of a numeric value should be rendered.
Read by integer and float formatters before emitting the magnitude.
Negative is the conventional default — only - for negative values,
nothing for non-negatives. Always is useful for diffs or coordinates
where every value should carry an explicit sign; Space reserves a
column so columns of mixed signs line up.
Examples
var opts = FormatOptions();
opts.sign = .Always;
(3).format(options: opts); // "+3"
(-3).format(options: opts); // "-3"
opts.sign = .Space;
(3).format(options: opts); // " 3"Cases
case Always
case AlwaysAlways show a sign — + for non-negative, - for negative.
case Negative
case NegativeShow - for negative values, no prefix for zero or positive (default).
case Space
case SpaceUse a leading space for non-negative, - for negative; keeps mixed-sign columns aligned.
ImplementsEquatable
Associated Types
type Output = Bool
type Output = BoolMethods
public func equal(to: Self) -> Bool
public func equal(to: Self) -> BoolBridges Equal.equal(to:) to Equatable.isEqual(to:).
public func isEqual(to: Sign) -> Bool
public func isEqual(to: Sign) -> BoolReturns true if both cases are the same variant.
Used by Equatable to lift case identity into a Bool for
composite comparisons (see FormatOptions.isEqual).
Examples
Sign.Always.isEqual(to: .Always); // true
Sign.Negative.isEqual(to: .Always); // falsepublic func notEqual(to: Self) -> Bool
public func notEqual(to: Self) -> BoolDefault !=: delegates to == so there's a single source of truth.
ImplementsMatchable
Methods
public func matches(Sign) -> Bool
public func matches(Sign) -> BoolPattern-match form of equality — delegates to isEqual.
Examples
Sign.Space.matches(.Space); // true
Defined in lang/std/text/format.ks