Alignment
public enum AlignmentHorizontal alignment of formatted output within a fixed field width.
Pairs with FormatOptions.width and FormatOptions.fill to position
shorter values inside the requested column. When the value is already at
least as wide as the field, alignment has no visible effect. The
formatter for String is the canonical consumer; numeric and boolean
formatters honour the same convention.
Examples
var opts = FormatOptions();
opts.width = .Some(8);
opts.alignment = .Right;
"ab".format(options: opts); // " ab"
opts.alignment = .Center;
"ab".format(options: opts); // " ab "Cases
case Center
case CenterPad on both sides; if the padding is odd, the extra space goes on the right.
case Left
case LeftPad on the right; the value sits flush against the left edge of the field.
case Right
case RightPad on the left; the value sits flush against the right edge of the field.
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: Alignment) -> Bool
public func isEqual(to: Alignment) -> BoolReturns true if both cases are the same variant.
Equality is structural — there are no payloads. Used by the
Equatable conformance so FormatOptions.isEqual can fall through
without payload comparisons.
Examples
Alignment.Left.isEqual(to: .Left); // true
Alignment.Left.isEqual(to: .Center); // 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(Alignment) -> Bool
public func matches(Alignment) -> BoolPattern-match form of equality — delegates to isEqual.
Lets Alignment appear in match patterns against another value.
Examples
Alignment.Right.matches(.Right); // true
Defined in lang/std/text/format.ks