#deprecated #attributes #version #macro #removal #force #deprecate

macro deprecate-until

Rust attribute to force deprecated item removal at a specified version

2 releases

0.1.1 Nov 29, 2023
0.1.0 Jul 15, 2023

#2111 in Development tools

Download history 1223/week @ 2023-12-23 2925/week @ 2023-12-30 2615/week @ 2024-01-06 4273/week @ 2024-01-13 4779/week @ 2024-01-20 6221/week @ 2024-01-27 4346/week @ 2024-02-03 5298/week @ 2024-02-10 4954/week @ 2024-02-17 5594/week @ 2024-02-24 5088/week @ 2024-03-02 4352/week @ 2024-03-09 4784/week @ 2024-03-16 4855/week @ 2024-03-23 5462/week @ 2024-03-30 8615/week @ 2024-04-06

24,599 downloads per month
Used in 20 crates (via pathfinding)

Apache-2.0/MIT

10KB
99 lines

deprecate-until

Current Version Documentation License: Apache-2.0/MIT

This crate introduces a new deprecate_until attribute which helps crate authors not to remove to delete obsolete items when some version is reached. When the specified semver condition is verified, the crate will not compile anymore and hopefully this will be caught by the CI or by cargo install before the release actually happens.

Usage

The deprecate_until attribute supports the same arguments as deprecate, i.e., note and since. It also requires a remove argument, which is a semver requirement expression in a string.

Example

The following code

use deprecate_until::deprecate_until;

#[deprecate_until(remove = ">= 4.x", note = "use `some_new_function` instead")]
fn old_function() {
    todo!()
}

will give a warning when version 3.8 of the crate is used in a project:

warning: use of deprecated function `old_function`: use `some_new_function` instead (removal scheduled for version >= 4.x)
  |
4 | fn old_function() {
  |    ^^^^^^^^^^^^

It will also cause a compilation error in version 4.0.0 of the crate if you forgot to remove it:

error: version `4.0.0` matches `>= 4.x`, item should be removed
  |
3 | #[deprecate_until(remove = ">= 4.x", note = "use `some_new_function` instead")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Dependencies

~0.5–1MB
~22K SLoC