-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support struct
in struct
#26
Conversation
@@ -3,25 +3,38 @@ | |||
func elementString<T>(_ x: T, debug: Bool, pretty: Bool) -> String { | |||
let mirror = Mirror(reflecting: x) | |||
|
|||
let typeName = type(of: x) | |||
let typeName = String(describing: mirror.subjectType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bugfix: not retrieve really type name when T
is Any
type.
.map { $0.indent(size: prefix.count) } | ||
.joined(separator: ",\n") | ||
// Optional<T> | ||
if typeName.starts(with: "Optional<") { // TODO: better judge is exist? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: better judge is exist?
As you've mentioned in slack, we can use displayStyle
property of Mirror type.
https://developer.apple.com/documentation/swift/mirror/displaystyle
if typeName.starts(with: "Optional<") { // TODO: better judge is exist? | |
if case .optional = mirror.displayStyle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion is not confirmed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for comment, I'll change it in another PR :-)
Co-Authored-By: sahara-ooga <performa532@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙆♀️🙆♂️
Support
struct
instruct
such asDog
hasOwner
. (and some refactoring)