as(_:)
Attempts to load an instance of some FixedWidthInteger
from this variant.
func `as`<Integer>(_: Integer.Type) throws -> Integer? where Integer : FixedWidthInteger
Returns
An integer derived from the payload of this variant if it matches one of int32(_:)
, int64(_:)
, or timestamp(_:)
, and it can be represented exactly by T
; nil otherwise.
The decimal128(_:)
, double(_:)
, and millisecond(_:)
variants will not match.
This method reports failure in two ways — it returns nil on a type mismatch, and it throws an IntegerOverflowError
if this variant was an integer, but it could not be represented exactly by T
.