Skip to content

Commit f9831e4

Browse files
committed
Add README.md
1 parent 59a68cc commit f9831e4

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "feature-gate"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
authors = ["Markus Mayer"]
55
description = "A simple macro for feature-gating modules and types"
66
repository = "https://github.com/sunsided/feature-gate"

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Simple documented feature gates
2+
3+
This crates provides the `feature_gate` and `feature_gate_ex`
4+
macros for simple `#[cfg(feature = "...")]` macros that are properly
5+
documented on docs.rs.
6+
7+
## Stable Rust
8+
9+
Note that for it to work properly on stable Rust, the following needs to be
10+
added to `Cargo.toml` for the time being (see [Metadata for custom builds](https://docs.rs/about/metadata)):
11+
12+
```toml
13+
[package.metadata.docs.rs]
14+
all-features = true
15+
rustdoc-args = ["--cfg", "docsrs"]
16+
```
17+
18+
## Example
19+
20+
The `feature_gate` macro allows the specification of a single feature:
21+
22+
```rust
23+
use feature_gate::feature_gate;
24+
25+
#[feature_gate("test")]
26+
struct FeatureGated;
27+
28+
#[test]
29+
fn it_works() {
30+
let _ = FeatureGated {};
31+
}
32+
```
33+
34+
The `feature_gate_ex` macro allows the specification of a complex set of requirements:
35+
36+
```rust
37+
use feature_gate::feature_gate_ex;
38+
39+
#[feature_gate_ex(any(test, feature = "test"))]
40+
struct FeatureGated;
41+
42+
#[test]
43+
fn it_works() {
44+
let _ = FeatureGated {};
45+
}
46+
```

0 commit comments

Comments
 (0)