在nom 5.0中,这段代码编译得很好:
fn escaped_space(i: &str) -> nom::IResult<&str, &str> {
nom::combinator::value(" ", nom::bytes::complete::tag("040"))(i)
}
assert_eq!(escaped_space(" "), Err(nom::Err::Error((" ", nom::error::ErrorKind::Tag))));但在当前版本中,6.2.1版本中的断言行不会编译,并出现类型不匹配错误E0308
expected Result<(&str, &str), nom::Err<nom::error::Error<&str>>>
found Result<_, nom::Err<(&str, nom::error::ErrorKind)>>我如何创建错误,使其现在与顶部的错误匹配?
发布于 2021-08-03 08:53:56
在nom 6中,有一个包含错误详细信息的additional struct,而不是nom 5中的元组:
Err(
nom::Err::Error(
nom::error::Error::new( //the new struct, instead of the tuple
" ",
nom::error::ErrorKind::Tag
)
)
)https://stackoverflow.com/questions/68629364
复制相似问题