3
我有这样一个枚举:如何解决“警告:未使用的变量”的枚举在Rust中的命名参数?
pub enum Tag<'a> {
Container { c: Vec<Tag<'a>> },
// ...
}
,当我尝试匹配:
impl<'a> Display for Tag<'a> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
Tag::Container { ref c } => write!(f, "{}", "container"),
// ...
}
}
}
我得到:
warning: unused variable: `c`, #[warn(unused_variables)] on by default
|
65 | Tag::Container{ref c} => write!(f, "{}", "container"),
和其他一些地方。
我试图使用_
,只是删除ref c
,但它都会导致错误。