Skip to main content

deprecated

Attribute deprecated 

Source
Expand description

Emits a warning during compilation when an item with this attribute is used. since and note are optional fields giving more detail about why the item is deprecated.

  • since: the version since when the item is deprecated.
  • note: the reason why an item is deprecated.

Example:

#[deprecated(since = "1.0.0", note = "Use bar instead")]
struct Foo;
struct Bar;

deprecated attribute helps developers transition away from old code by providing warnings when deprecated items are used. Note that during Cargo builds, warnings on dependencies get silenced by default, so you may not see a deprecation warning unless you build that dependency directly.

For more information, see the Reference on the deprecated attribute.