|
2 | 2 |
|
3 | 3 | Rust API stability attributes for the rest of us.
|
4 | 4 |
|
5 |
| -[](https://crates.io/crates/instability) |
6 |
| -[][documentation] |
7 |
| -[](LICENSE.md) |
8 |
| - |
9 |
| -[](https://github.com/ratatui-org/instability/actions) |
10 |
| -[](https://github.com/ratatui-org/instability/actions) |
| 5 | +[![Crate Badge]][Crate] [![Build Badge]][Build] [![Docs Badge]][Docs] [![License Badge]][License] |
| 6 | +![MSRV Badge] |
11 | 7 |
|
12 | 8 | ## Overview
|
13 | 9 |
|
14 |
| -This is a fork of the [Stability](https://crates.io/crates/stability) crate with the |
15 |
| -[blessing](https://github.com/sagebind/stability/issues/12) of the original maintainer Stephen M. |
16 |
| -Coakley ([@sagebind](https://github.com/sagebind)). This crate provides attribute macros for |
17 |
| -specifying API stability of public API items of a crate. For a quick example: |
| 10 | +This crate provides attribute macros for specifying API stability of public API items of a crate. It |
| 11 | +is a [fork] of the [Stability] original created by Stephen M. Coakley ([@sagebind]). |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +Add the `instability` crate to your `Cargo.toml` file: |
| 16 | + |
| 17 | +```shell |
| 18 | +cargo add instability |
| 19 | +``` |
| 20 | + |
| 21 | +Then, use the `#[instability::stable]` and `#[instability::unstable]` attributes to specify the |
| 22 | +stability of your API items: |
18 | 23 |
|
19 | 24 | ```rust
|
20 | 25 | /// This function does something really risky!
|
21 |
| -/// |
22 |
| -/// Don't use it yet! |
23 | 26 | #[instability::unstable(feature = "risky-function")]
|
24 | 27 | pub fn risky_function() {
|
25 |
| - unimplemented!() |
| 28 | + println!("This function is unstable!"); |
26 | 29 | }
|
27 |
| -``` |
28 |
| - |
29 |
| -Please check out the [documentation] for detailed usage. |
30 | 30 |
|
31 |
| -## Installation |
| 31 | +/// This function is safe to use! |
| 32 | +#[instability::stable(since = "1.0.0")] |
| 33 | +pub fn stable_function() { |
| 34 | + println!("This function is stable!"); |
| 35 | +} |
| 36 | +``` |
32 | 37 |
|
33 |
| -Install via Cargo by adding to your `Cargo.toml` file: |
| 38 | +A feature flag prefixed with "unstable-" will be created that can be used to enable unstable items. |
| 39 | +The macro will append an extra documentation comment that describes the stability of the item. The |
| 40 | +visibility of the item will be changed to `pub(crate)` when the feature is not enabled (or when the |
| 41 | +attribute is on an impl block, the entire block will be removed). |
34 | 42 |
|
35 |
| -```toml |
36 |
| -[dependencies] |
37 |
| -instability = "0.3" |
38 |
| -``` |
| 43 | +Check out the [Docs] for detailed usage. See [instability-example] for a complete example. |
39 | 44 |
|
40 |
| -### Supported Rust versions |
| 45 | +## MSRV |
41 | 46 |
|
42 |
| -The current release is only guaranteed to work with the latest stable Rust compiler. |
| 47 | +The minimum supported Rust version (MSRV) is 1.64.0. |
43 | 48 |
|
44 | 49 | ## License
|
45 | 50 |
|
46 |
| -This project's source code and documentation are licensed under the MIT license. See the [LICENSE](LICENSE.md) file for details. |
| 51 | +This project's source code and documentation are licensed under the MIT [License]. |
47 | 52 |
|
48 |
| -[documentation]: https://docs.rs/instability |
| 53 | +[Crate Badge]: https://img.shields.io/crates/v/instability |
| 54 | +[Build Badge]: https://img.shields.io/github/actions/workflow/status/ratatui/instability/check.yml |
| 55 | +[Docs Badge]: https://img.shields.io/docsrs/instability |
| 56 | +[License Badge]: https://img.shields.io/crates/l/instability |
| 57 | +[MSRV Badge]: https://img.shields.io/crates/msrv/instability |
| 58 | +[Crate]: https://crates.io/crates/instability |
| 59 | +[Build]: https://github.com/ratatui/instability/actions/workflows/check.yml |
| 60 | +[Docs]: https://docs.rs/instability |
| 61 | +[License]: ./LICENSE.md |
| 62 | +[stability]: https://crates.io/crates/stability |
| 63 | +[@Sagebind]: https://github.com/sagebind |
| 64 | +[fork]: https://github.com/sagebind/stability/issues/12 |
| 65 | +[instability-example]: https://crates.io/crates/instability-example |
0 commit comments