skip icon indicating copy to clipboard operation
skip copied to clipboard

Type mismatch when working with ForEach with generics

Open hepspl opened this issue 1 year ago • 3 comments

image

Am I doing something wrong here or

You may have to replace some generics or generic constraints with looser typing in order to transpile successfully. applies here?

I think it is not that complex so I hope that I just should rephrase that somehow. I tried several approaches but I can't make this work.

Any advice?

hepspl avatar May 10 '24 13:05 hepspl

I'm so sorry that we did not see this! I'll investigate right away and give you an update

aabewhite avatar May 14 '24 03:05 aabewhite

I'll need more time to consider a proper fix, but here is a workaround for you: constrain T to be both Hashable and Any. E.g.:

struct CustomDropdownOption<T> where T: Hashable, T: Any {
    ...
}

struct CustomDropDown<T>: View where T: Hashable, T: Any {
    ...
}

I'll let you know when we have a full fix in place. And again, very sorry for the delay! We appreciate the report, and please let us know if you run into additional problems or have any additional feedback.

aabewhite avatar May 14 '24 03:05 aabewhite

If you update to the latest SkipUI with File->Packages->Update to Latest in Xcode, you can remove the above workaround and go back to your original code

aabewhite avatar May 15 '24 00:05 aabewhite

Thank you very, it works indeed :)

hepspl avatar May 17 '24 12:05 hepspl