liveBook · Manning

Deprecation

As explained in Learn Rust in a Month of Lunches

The deprecated attribute marks a Rust item as discouraged for use and causes the compiler to issue a warning when it is used.

The #[deprecated] attribute marks an item, usually a function, as discouraged because it is no longer the preferred choice. Using it still compiles, but Rust emits a warning. section 13.1.5

Add note = "..." to explain why an item is deprecated, recommend a replacement, or warn that it may later be removed. IDEs may also show deprecated items with strikethrough highlighting. section 13.1.5

Pointing users to a replacement

Mark old_function as deprecated with a note directing users to new_function. Calling old_function produces the full note while the program still compiles.

How Learn Rust in a Month of Lunches covers it

How deep it goes
Explains attribute syntax, warnings, notes, replacements, and IDE highlighting without covering removal workflows.
Examples
Uses deprecated_function and old_function calls, compiler warnings, a replacement note, and IDE strikethrough highlighting.
What you can do after
Apply #[deprecated] to guide callers toward a replacement while preserving compilation.
How it connects
Connects attributes with compiler warnings, replacement functions, and IDE feedback.

Also explained in

Compare how 5 books explain deprecation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Rust in a Month of Lunches. The section links point to the parts of the book it draws on.