Macros 无法使用RSF机箱中的宏
我有一个项目试图使用以下宏: 编译时,会出现如下错误:Macros 无法使用RSF机箱中的宏,macros,rust,Macros,Rust,我有一个项目试图使用以下宏: 编译时,会出现如下错误: <rsfuzzy macros>:3:22: 3:41 error: failed to resolve. Use of undeclared type or module `fuzzy::mf` [E0433] <rsfuzzy macros>:3 let mut vars : Vec < fuzzy:: mf:: MfType > = Vec:: new ( ) ; $ ( 当我使用所建议的“ex
<rsfuzzy macros>:3:22: 3:41 error: failed to resolve. Use of undeclared type or module `fuzzy::mf` [E0433]
<rsfuzzy macros>:3 let mut vars : Vec < fuzzy:: mf:: MfType > = Vec:: new ( ) ; $ (
当我使用所建议的“extern板条箱rsfuzzy as fuzzy”时,我会得到另一个错误列表:
failed to resolve. Use of undeclared type or module `TXParserError` [E0433]at line 9 col 1 in <rsfuzzy macros>
unresolved name `TXParserError::from_complex` [E0425]at line 9 col 1 in <rsfuzzy macros>
^~~~~~~~~~~~~~~~~~~
rsfuzzy板条箱显示出不良的编码实践,这似乎是导致此问题的原因。以下是一个例子:
是的,我试过了,它解决了错误,但是出现了新的错误。
failed to resolve. Use of undeclared type or module `TXParserError` [E0433]at line 9 col 1 in <rsfuzzy macros>
unresolved name `TXParserError::from_complex` [E0425]at line 9 col 1 in <rsfuzzy macros>
^~~~~~~~~~~~~~~~~~~
#[macro_export]
macro_rules! fz_input_var {
( $( $x:expr ),* ) => {
{
let mut vars: Vec<fuzzy::mf::MfType> = Vec::new();
$(
let value = match $x.0 {
"triangle" => fuzzy::mf::Triangle::new($x.1, $x.2),
"trapezoid" => fuzzy::mf::Trapezoid::new($x.1, $x.2),
"up" => fuzzy::mf::Up::new($x.1, $x.2),
"down" => fuzzy::mf::Down::new($x.1, $x.2),
_ => return Err(TXParserError::from_complex("No MF found for type", $x.0))
};
vars.push(value);
)*
fuzzy::InputVar::new(vars)
}
};
}
extern crate rsfuzzy as fuzzy;