Skip to content

Commit efbddba

Browse files
committed
improve docs of cfg method
1 parent bbeb773 commit efbddba

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ctest/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,26 @@ impl TestGenerator {
251251
/// Set a `--cfg` option with which to expand the Rust FFI crate.
252252
///
253253
/// By default the Rust code is run through expansion to determine what C
254-
/// APIs are exposed (to allow differences across platforms). The `k`
255-
/// argument is the `#[cfg]` value to define, and `v` is an optional value
256-
/// for differentiating between `#[cfg(foo)]` and `#[cfg(foo = "bar")]`.
254+
/// APIs are exposed (to allow differences across platforms).
255+
///
256+
/// The `k` argument is the `#[cfg]` value to define, while `v` is the
257+
/// optional value of `v`:
258+
///
259+
/// * `k == "foo"` and `v == None` makes `#[cfg(foo)]` expand. That is,
260+
/// `cfg!(foo)` expands to `true`.
261+
///
262+
/// * `k == "bar"` and `v == Some("baz")` makes `#[cfg(bar = "baz")]`
263+
/// expand. That is, `cfg!(bar = "baz")` expands to `true`.
257264
///
258265
/// # Examples
259266
///
260267
/// ```no_run
261268
/// use ctest::TestGenerator;
262269
///
263270
/// let mut cfg = TestGenerator::new();
264-
/// cfg.cfg("foo", None)
265-
/// .cfg("bar", Some("baz"));
271+
/// cfg.cfg("foo", None) // cfg!(foo)
272+
/// .cfg("bar", Some("baz")); // cfg!(bar = "baz")
273+
/// ```
266274
pub fn cfg(&mut self, k: &str, v: Option<&str>) -> &mut TestGenerator {
267275
self.cfg.push((k.to_string(), v.map(|s| s.to_string())));
268276
self

0 commit comments

Comments
 (0)