Contents

bitCast(_:to:)

Returns the bits of the given instance, interpreted as having the specified type.

Declaration

func bitCast<T, U>(_ original: T, to type: U.Type) -> U where T : ConvertibleToBytes, U : ConvertibleFromBytes

Parameters

  • original:

    The instance to cast to type.

  • type:

    The type to cast original to.

Return Value

A new instance of type U, cast from original.

Discussion

T and U must have the same-sized memory representation. If they don’t, this function will trap.

See Also

Safe Access to Raw Bytes