Skip to content

Commit e8cd0c2

Browse files
authored
Merge pull request rust-lang#35 from gnzlbg/doc0
improve docs of cfg method
2 parents 5360c25 + e9355e7 commit e8cd0c2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,26 @@ impl TestGenerator {
262262
/// Set a `--cfg` option with which to expand the Rust FFI crate.
263263
///
264264
/// By default the Rust code is run through expansion to determine what C
265-
/// APIs are exposed (to allow differences across platforms). The `k`
266-
/// argument is the `#[cfg]` value to define, and `v` is an optional value
267-
/// for differentiating between `#[cfg(foo)]` and `#[cfg(foo = "bar")]`.
265+
/// APIs are exposed (to allow differences across platforms).
266+
///
267+
/// The `k` argument is the `#[cfg]` value to define, while `v` is the
268+
/// optional value of `v`:
269+
///
270+
/// * `k == "foo"` and `v == None` makes `#[cfg(foo)]` expand. That is,
271+
/// `cfg!(foo)` expands to `true`.
272+
///
273+
/// * `k == "bar"` and `v == Some("baz")` makes `#[cfg(bar = "baz")]`
274+
/// expand. That is, `cfg!(bar = "baz")` expands to `true`.
268275
///
269276
/// # Examples
270277
///
271278
/// ```no_run
272279
/// use ctest::TestGenerator;
273280
///
274281
/// let mut cfg = TestGenerator::new();
275-
/// cfg.cfg("foo", None)
276-
/// .cfg("bar", Some("baz"));
282+
/// cfg.cfg("foo", None) // cfg!(foo)
283+
/// .cfg("bar", Some("baz")); // cfg!(bar = "baz")
284+
/// ```
277285
pub fn cfg(&mut self, k: &str, v: Option<&str>) -> &mut TestGenerator {
278286
self.cfg.push((k.to_string(), v.map(|s| s.to_string())));
279287
self

0 commit comments

Comments
 (0)