Contents

FormatInput

The type this format style accepts as input.

Declaration

associatedtype FormatInput

Discussion

Swift type inference uses this value to determine which static accessors are available at a given call point. For example, when you format an Int32, you can use the static number property that provies a IntegerFormatStyle<Int32>, as seen in the following example. This works because the style’s input type IntegerFormatStyle/FormatInput is a BinaryInteger generically constrained to the Int32 type.

let perihelionDistanceToSunInKm: Int32 = 147098291
perihelionDistanceToSunInKm.formatted(.number
    .notation(.scientific)) // "1.470983E8"

See Also

Declaring input and output types