Expand description
Swift type manglings, built rather than counted.
A mangled type name is length-prefixed: SwiftUI.ContentTransition is
7SwiftUI17ContentTransitionV, where the 7 and the 17 are the lengths of
the two identifiers and the V says it is a struct. Writing those by hand is
arithmetic in a string literal, and getting one wrong does not fail to
compile — it resolves to nothing, or to the wrong type, at run time. This
crate shipped 14decimalDigits for a name thirteen characters long, and
found out through a panic in an unrelated modifier.
So the lengths are counted by the compiler’s len() instead of by eye:
swift_type!(SwiftUI.ContentTransition) // 7SwiftUI17ContentTransitionV
swift_type!(enum SwiftUI.Font.Design) // 7SwiftUI4FontV6DesignO
swift_type!(opt SwiftUI.Color) // 7SwiftUI5ColorVSg
swift_type!([SwiftUI.EdgeInsets]) // Say7SwiftUI10EdgeInsetsVGSymbols — functions, getters, witness tables — are not covered. Their
mangling encodes argument types, substitutions and calling conventions, and
is read off the export table rather than constructed; see
crate::resolve.
Enums§
Constants§
- BOOL
Swift.Bool.- DATE
Foundation.Date— oneDoubleof seconds since the reference date.- DOUBLE
Swift.Double.- INT
Swift.Int.- NEVER
Swift.Never.- STRING
Swift.String.
Functions§
- again
- A SwiftUI type written where the module is already in the substitution table.
- array
Array<T>.- bound
- A generic type applied to arguments —
Binding<Bool>isbound(BINDING, &[BOOL]). - demangle
- Turn a mangled name back into something readable, for diagnostics.
- existential
- A protocol existential —
any Erroriss5Error_p. - imported
- A type imported from Objective-C or C.
- modified
ModifiedContent<AnyView, M>— what applying a modifier to anAnyViewproduces, and so the result type of most of this crate’s bindings.- modified_
content ModifiedContent<AnyView, M>— the result type of most modifiers.- nested
- A type nested inside one of the shorthand types, such as
String.Index. - nominal
- A nominal type, named by its module and the path to it.
- opt
T?.- optional
Optional<T>, which isTwithSgafter it.- pack
- A generic type applied to a parameter pack.
- range
Range<T>.- set
Set<T>, which isShapplied to one argument.- stdlib
- A standard-library type with no shorthand, such as
Result. - ty
SwiftUI.Name, a struct.- ty_
class SwiftUI.Name, a class.- ty_enum
SwiftUI.Name, an enum.