File tree 2 files changed +47
-1
lines changed 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " feature-gate"
3
- version = " 0.1.0 "
3
+ version = " 0.1.1 "
4
4
authors = [" Markus Mayer" ]
5
5
description = " A simple macro for feature-gating modules and types"
6
6
repository = " https://github.com/sunsided/feature-gate"
Original file line number Diff line number Diff line change
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
+ ```
You can’t perform that action at this time.
0 commit comments