我想标记函数/方法已过时。我尝试使用 deprecated
属性:
#[deprecated]
fn old_way_of_doing_it() {
但是这会产生一个错误:error: stability attributes may not be used outside of the standard library
有没有一种方法可以使编译器警告我的库的使用者函数已被弃用?我没有经验,但我正在考虑尝试编译器插件和自定义属性,但我猜这需要使用者也使用插件,这可能是不合理的(或者对我来说需要太多工作了?)另外一个好奇的问题,为什么弃用属性只适用于标准库?
error: This deprecation annotation is useless = note: #[warn(unused_imports)] on by default
- xliivimpl Trait for Type
中放置弃用的属性。请将属性直接放在trait Trait
内的方法上。 - kennytm