I need to build a regex string within my init and initialize a property with it. I would like to use 'some RegexComponent' for the type since the compiler knows the type and the type can get rather unwieldy with many captures (especially if they are optional). This fails though because the compiler doesn't infer the type:
struct Test {
let regex: some RegexComponent
init(_ searchString: String) {
regex = Regex {
searchString
}
}
}
let t = Test("xxx")
let s = "xxxyyy"
s.prefixMatch(of: t.regex)