๐ฎMirror
๐พ ็จๅผ๏ผpaiza.io
HasMirrors - use Mirror to inspect types.
CaseReflectable - inspect enum case.
NonNominalTypeWrapper - help inspect non-nominal types.
enum case pattern - use Mirror to pattern match an enum case.
// --------------------
// Type aliases
// --------------------
// An element of the reflected instanceโs structure
// label: nil | stored property name | enum case name.
typealias Mirror.Child = (label: String?, value: Any)
// The type used to represent substructure.
typealias Mirror.Children = AnyCollection<Mirror.Child>
// -------------
// Types
// -------------
// Playgrounds and debugger will use this as suggestion to show subject.
enum Mirror.DisplayStyle {
case `class`
case collection
case dictionary
case `enum`
case optional
case set
case `struct`
case tuple
}Swift โฉ
String โฉ
.init(reflecting:) - String(reflecting: subject) CustomDebugStringConvertible โ CustomStringConvertible โ TextOutputStreamable โ Swift standard library
.init(describing:) - String(describing: subject) TextOutputStreamable โ CustomStringConvertible โ CustomDebugStringConvertible โ Swift standard library
Swift.org โฉ How Mirror Works - how Mirror works under the hood.
filter cases - use Mirror to do pattern matching.
HasMirrors - helper protocol to mirror subjects.
CaseReflectable - use Mirror to get enum case name/associated values.
NonNominalTypeWrapper - wrap non-nominal types to conform to Loggable.
้้ตๅญ๏ผmeta programming, reflection
Last updated
Was this helpful?