有没有办法将Rust的功能标志支持应用到函数参数?我有一个函数,它接受一串输入,但其中一个输入应该只在功能处于活动状态时才被传递.当然,我可以将该参数设置为可选参数,如下所示:
pub fn my_function(input1: usize, input2: String, input3: Option<Vec<u32>>) -> () {...}
但有没有一种方法可以使用功能标志并定义如下内容:
pub fn my_function(
input1: usize,
input2: String,
#[cfg(feature = "my-feature")]
input3: Vec<u32>
) -> () {...}
同样,后来又称其为:my_function(0, "", #[cfg(feature = "my-feature")] vec![0])
?