E4234#
编译器诊断名称:regex_kind_mismatch。
正则表达式的种类与输入不匹配。文本正则表达式(re"..." 和 Regex 常量)匹配文本;字节正则表达式(reb"..." 和 BytesRegex 常量)匹配字节。
错误示例#
///|
pub fn matches(text : String) -> Bool {
ignore(text)
text =~ reb"abc"
}
建议#
文本输入应使用文本正则表达式,字节输入应使用字节正则表达式。改变正则表达式的种类不会在文本与字节之间转换输入。
///|
pub fn matches(text : String) -> Bool {
text =~ re"abc"
}
///|
test {
assert_true(matches("abc"))
assert_false(matches("123"))
}