llogiq
llogiq

Reputation: 14511

How to correctly deprecate a crate feature

I have a crate that up to now had a feature that will no longer be needed. I'd like to deprecate it, but have no idea how.

My plan so far is to make it a default feature first, but then what?

Upvotes: 6

Views: 362

Answers (1)

Kornel
Kornel

Reputation: 100070

You can put this on functions that previously depended on this feature:

#[cfg_attr(feature = "unwanted", deprecated(note = "don't use the feature"))]

This will show a warning only if that feature has been enabled. However, the warning will be slightly misleading, as it will point to the function.

When you completely remove the feature, you should increase the major version.

Upvotes: 2

Related Questions