Skip to content
Discussion options

You must be logged in to vote

Note that SKIP DECLARE: does work, but the problem is that Skip is short-circuiting before it is even evaluated because it sees its limitation on the generic constraint. We don't parse the contents of SKIP DECLARE, so we don't see that it is overcoming the generic constraint limitations by redefining the type parameter.

One way to work around this could be to externalize that constraint as a conditional typealias. Something like:

#if !SKIP
typealias SequenceOfStrings<S> = S where S: Sequence, S.Element == [String]
#else
typealias SequenceOfStrings = Sequence<Array<String>>
#endif

public func searchSync<S>(_ text: String, in aList: SequenceOfStrings<S>) -> [FuzzySrchResult] {
}

That way y…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dfabulich
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants