Generic constraint to enforce value type?

hi, this may sound like a stupid question as I think the answer is "no" but I would like to confirm since I don't have that much experience with Swift. Is there a way to constrain a protocol's associated type OR a generic type to use structs only?

I'm writing this generic function and I wish only structs to be passed as arguments.

Thanks

1 Like

Short answer, currently no. Not long answer, look up AnyValue on this forum (though it usually includes enum).

2 Likes
Terms of Service

Privacy Policy

Cookie Policy