An attribute for deprecation

Minimum Rust version: 1.9

If you're writing a library, and you'd like to deprecate something, you canuse the deprecated attribute:

2. #![allow(unused_variables)]
3. fn main() {
4. #[deprecated(
5. since = "0.2.1",
6. note = "Please use the bar function instead"
7. )]
8. pub fn foo() {
9. // ...
10. }
11. }

This will give your users a warning if they use the deprecated functionality:

1. Compiling playground v0.0.1 (file:///playground)
2. warning: use of deprecated item 'foo': Please use the bar function instead
3. --> src/main.rs:10:5
4. |
5. 10 |     foo();
6. |     ^^^
7. |
8. = note: #[warn(deprecated)] on by default

Both since and note are optional.

since can be in the future; you can put whatever you'd like, and what's put inthere isn't checked.