struct AnyField
extension AnyField : Equatable, Field, Hashable, RawRepresentable, Sendable
A type-erased Field
.
-
Undocumented
Declaration
Swift
init<T>(erasing field: T) where T : Field
-
Creates a type-erased
UnknownField
with the given raw value.Declaration
Swift
init(rawValue: UInt32)
-
The number identifying the attribute in the trait, or the field in a Command, Event, etc.
Declaration
Swift
var id: UInt32 { get }
-
The type of the field.
Declaration
Swift
var type: FieldType { get }
-
The corresponding value of the raw type.
A new instance initialized with
rawValue
will be equivalent to this instance. For example:enum PaperSize: String { case A4, A5, Letter, Legal } let selectedSize = PaperSize.Letter print(selectedSize.rawValue) // Prints "Letter" print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) // Prints "true"
Declaration
Swift
var rawValue: UInt32 { get }
-
Casts the field to the given type.
Declaration
Swift
func cast<T>(_ type: T.Type = T.self) -> T? where T : Field
-
Returns true if the field is of the given type.
Declaration
Swift
func `is`<T>(_ type: T.Type = T.self) -> Bool where T : Field
-
Returns true if the field is equal to the other field.
Declaration
Swift
func isEqual(to other: any Field) -> Bool
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Swift
static func == (lhs: AnyField, rhs: AnyField) -> Bool
Parameters
lhs
A value to compare.
rhs
Another value to compare.