Alignment

public enum Alignment

Horizontal 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

Pad on both sides; if the padding is odd, the extra space goes on the right.

case Left

Pad on the right; the value sits flush against the left edge of the field.

case Right

Pad on the left; the value sits flush against the right edge of the field.

ImplementsEquatable

Associated Types

type Output = Bool

Methods

public func equal(to: Self) -> Bool

Bridges Equal.equal(to:) to Equatable.isEqual(to:).

public func isEqual(to: Alignment) -> Bool

Returns 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); // false
public func notEqual(to: Self) -> Bool

Default !=: delegates to == so there's a single source of truth.

ImplementsMatchable

Methods

public func matches(Alignment) -> Bool

Pattern-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