当我尝试将 nom's 转换CompleteStr
为 a String
in 时named!
,我收到一条错误消息,指出它正在返回 a Result
。
named!(letter_cs<CompleteStr,String>,
map_res!(
alpha,
|CompleteStr(s)| String::from(s)
)
);
会抛出错误
error[E0308]: mismatched types
--> src/year2015/day_7.rs:16:1
|
16 | / named!(letter_cs<CompleteStr,String>,
17 | | map_res!(
18 | | alpha,
19 | | |CompleteStr(s)| String::from(s)
20 | | )
21 | | );
| |__^ expected struct `std::string::String`, found enum `std::result::Result`
|
= note: expected type `std::string::String`
found type `std::result::Result<_, _>`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)