https://github.com/evenfurther/deprecate-until
Rust attribute to force deprecated item removal at a specified version
https://github.com/evenfurther/deprecate-until
Last synced: 6 months ago
JSON representation
Rust attribute to force deprecated item removal at a specified version
- Host: GitHub
- URL: https://github.com/evenfurther/deprecate-until
- Owner: evenfurther
- Created: 2023-07-15T14:18:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-23T05:58:08.000Z (7 months ago)
- Last Synced: 2025-11-23T07:17:19.435Z (7 months ago)
- Language: Rust
- Size: 84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# deprecate-until
[](https://crates.io/crates/deprecate_until)
[](https://docs.rs/deprecate_until)
[](#license)
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](https://semver.org/) requirement
expression in a string.
## Example
The following code
```rust
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:
```txt
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:
```txt
error: version `4.0.0` matches `>= 4.x`, item should be removed
|
3 | #[deprecate_until(remove = ">= 4.x", note = "use `some_new_function` instead")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```