Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 754
llogiq Avatar asked Jul 06 '19 21:07

llogiq


1 Answers

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.

like image 98
Kornel Avatar answered Oct 06 '22 03:10

Kornel