-
Notifications
You must be signed in to change notification settings - Fork 67
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
Implement AnyView.init(_fromValue:) #20
base: master
Are you sure you want to change the base?
Conversation
…using C’s extern function
@Cosmo I took the contents of this PR and managed to make it a bit more generic: https://github.com/nerdsupremacist/AssociatedTypeRequirementsKit. I can switch it to that implementation if you feel like it, but I understand if you want to keep the number of dependencies of this as low as possible |
@nerdsupremacist I finally took some time to take a look at the amazing work you did. To be honest, I won't mind having this as a dependency. |
Cool! I've changed the PR to only use the library instead ;) |
This PR implements
AnyView.init(_fromValue:)
.I need this functionality for my library.
Since I didn't know how to implement it, I first checked how you do it here, and noticed that you didn't. But it was marked as TODO.
I guess you probably found to be a real pain in the a**.
I hope you don't hate my implementation. It uses some runtime functions, symbol lookups and exploits how protocol conformance looks during runtime.
It's not exactly the simplest implementation. But I couldn't figure out a simpler way to do it.
I had to add a C target to be able to include
_GNU_SOURCE
under linux, becausedlopen
is not defined for Swift in Linux. Refer to this forum post for more info.I have not tested this on linux, but it should work.
I added two tests which you can run to check it.