From 95a9ea3023070c43f287776f6c4ceb4fa9083013 Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 19 Apr 2024 12:06:57 +0800 Subject: [PATCH] docs: document features closes #3 --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 12 +++++++++--- src/lib.rs | 5 +++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89d3978..f17af2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,6 +400,7 @@ dependencies = [ "codspeed", "colored", "csv", + "document-features", "futures", "itertools", "itertools-num", @@ -473,6 +474,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "either" version = "1.10.0" @@ -788,6 +798,12 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "log" version = "0.4.21" diff --git a/Cargo.toml b/Cargo.toml index f763b81..ce9c0df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,8 @@ plotters = { version = "^0.3.5", default-features = false, features = [ codspeed = { version = "2.4.1", optional = true } colored = { version = "2.1.0", optional = true } +document-features = { version = "0.2", optional = true } + [dev-dependencies] tempfile = "3.10.1" approx = "0.5.1" @@ -75,16 +77,20 @@ stable = [ "async_std", ] default = ["rayon", "plotters", "cargo_bench_support"] + +## Enables [codspeed](https://codspeed.io) codspeed = ["dep:codspeed", "dep:colored"] -# Enable async/await support +## Enables async/await support async = [] -# These features enable built-in support for running async benchmarks on each different async -# runtime. +## Enables built-in support for running async benchmarks on futures. async_futures = ["futures/executor", "async"] +## Enables built-in support for running async benchmarks on smol. async_smol = ["smol", "async"] +## Enables built-in support for running async benchmarks on tokio. async_tokio = ["tokio", "async"] +## Enables built-in support for running async benchmarks on async-std. async_std = ["async-std", "async"] # This feature _currently_ does nothing except disable a warning message, but in 0.4.0 it will be diff --git a/src/lib.rs b/src/lib.rs index 17a1ffa..d45ea8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,11 @@ //! to performance are real, not measurement noise. //! * Produces detailed charts, providing thorough understanding of your code's //! performance behavior. +//! +//! ## Feature flags +#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +//! #![allow(clippy::style, clippy::complexity)] #![warn(bare_trait_objects)]