给定以下活动模式:
let (| HasMatch |) (x:string) =
if x.Contains("0") then Some()
else None;;
以及以下模式匹配函数:
let testFn x = function
| HasMatch i -> printfn "%A" i
| _ -> printf "nope";;
最后一行的通配符模式说warning FS0026: This rule will never be matched
我看到的所有示例似乎都推断出部分活动模式必须返回Some('a)
以匹配,并且返回的模式None
被通配符捕获。错误似乎有不同的说法。
我错过了什么?