diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3447801..df56b03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@nightly - - run: cargo test --features tests --no-fail-fast + - run: cargo test --all-features --no-fail-fast bench: name: bench @@ -27,8 +27,8 @@ jobs: - uses: dtolnay/rust-toolchain@nightly - run: cargo bench --all-features --no-run - clippy: - name: clippy + clippy-all-features: + name: clippy-all-features runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -37,6 +37,16 @@ jobs: components: clippy - run: cargo clippy --all-features --all-targets -- -D warnings + clippy-no-features: + name: clippy-no-features + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@nightly + with: + components: clippy + - run: cargo clippy --all-targets -- -D warnings + docs: name: docs runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index c379b84..12401bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,13 +5,14 @@ edition = "2021" authors = ["Riccardo Mazzarini "] [features] -fzf-v1 = [] -fzf-v2 = [] +fzf-v1 = ["__any-metric"] +fzf-v2 = ["__any-metric"] # Private features. -bench = ["tests"] -into-score = [] -tests = ["fzf-v1", "fzf-v2"] +__any-metric = [] +__benches = [] +__into-score = [] +__tests = [] [dependencies] memchr = "2" @@ -19,28 +20,32 @@ memchr = "2" [dev-dependencies] criterion = "0.5" +[[test]] +name = "fzf_common" +required-features = ["__tests"] + [[test]] name = "fzf_v1" -required-features = ["tests"] +required-features = ["__tests"] [[test]] name = "fzf_v2" -required-features = ["tests"] +required-features = ["__tests"] [[bench]] name = "fzf_common" harness = false -required-features = ["bench"] +required-features = ["__benches"] [[bench]] name = "fzf_v1" harness = false -required-features = ["bench"] +required-features = ["__benches"] [[bench]] name = "fzf_v2" harness = false -required-features = ["bench"] +required-features = ["__benches"] [[example]] name = "cities" diff --git a/src/lib.rs b/src/lib.rs index 2182b70..07e1e2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,16 +81,24 @@ extern crate alloc; +#[cfg(feature = "__any-metric")] mod candidate; mod case_sensitivity; +#[cfg(feature = "__any-metric")] mod matched_ranges; mod metric; +#[cfg(feature = "__any-metric")] mod metrics; +#[cfg(feature = "__any-metric")] mod normalize; +#[cfg(feature = "__any-metric")] mod utils; +#[cfg(feature = "__any-metric")] use candidate::{Candidate, CandidateMatches}; pub use case_sensitivity::CaseSensitivity; +#[cfg(feature = "__any-metric")] use matched_ranges::MatchedRanges; pub use metric::Metric; +#[cfg(feature = "__any-metric")] pub use metrics::*; diff --git a/src/metrics/fzf/distance.rs b/src/metrics/fzf/distance.rs index cf10d8c..19badd8 100644 --- a/src/metrics/fzf/distance.rs +++ b/src/metrics/fzf/distance.rs @@ -43,7 +43,7 @@ impl FzfDistance { /// This is not part of the public API and should not be relied upon. /// /// It's only used internally for testing and debugging purposes. - #[cfg(any(feature = "into-score", feature = "tests"))] + #[cfg(any(feature = "__into-score", feature = "__tests"))] #[inline(always)] pub fn into_score(self) -> Score { self.0 diff --git a/src/metrics/fzf/fzf_v1.rs b/src/metrics/fzf/fzf_v1.rs index a18198d..6f8ae34 100644 --- a/src/metrics/fzf/fzf_v1.rs +++ b/src/metrics/fzf/fzf_v1.rs @@ -97,7 +97,7 @@ impl FzfV1 { } /// Returns the current scoring scheme. This is only used for testing. - #[cfg(feature = "tests")] + #[cfg(feature = "__tests")] pub fn scheme(&self) -> &Scheme { &self.scoring_scheme } diff --git a/src/metrics/fzf/fzf_v2.rs b/src/metrics/fzf/fzf_v2.rs index 24a57ca..7b4061d 100644 --- a/src/metrics/fzf/fzf_v2.rs +++ b/src/metrics/fzf/fzf_v2.rs @@ -107,7 +107,7 @@ impl FzfV2 { } /// Returns the current scoring scheme. This is only used for testing. - #[cfg(feature = "tests")] + #[cfg(feature = "__tests")] pub fn scheme(&self) -> &Scheme { &self.scoring_scheme } diff --git a/src/metrics/fzf/parser.rs b/src/metrics/fzf/parser.rs index e4cc61a..08647e8 100644 --- a/src/metrics/fzf/parser.rs +++ b/src/metrics/fzf/parser.rs @@ -396,7 +396,7 @@ impl<'buf> Iterator for Words<'buf, '_> { } /// TODO: docs -#[cfg(feature = "tests")] +#[cfg(feature = "__tests")] #[doc(hidden)] pub fn parse(s: &str) -> FzfQuery<'static> { let parser = Box::leak(Box::new(FzfParser::new())); @@ -561,7 +561,7 @@ mod patterns_tests { } } -#[cfg(feature = "tests")] +#[cfg(feature = "__tests")] #[doc(hidden)] pub fn words(s: &str) -> impl Iterator { let mut buf = Vec::new(); diff --git a/tests/fzf_common.rs b/tests/fzf_common.rs index 2eb1597..a11a44e 100644 --- a/tests/fzf_common.rs +++ b/tests/fzf_common.rs @@ -579,12 +579,12 @@ mod utils { } fn scheme(&self) -> &norm::fzf::Scheme { - #[cfg(feature = "tests")] + #[cfg(feature = "__tests")] { self.scheme() } - #[cfg(not(feature = "tests"))] + #[cfg(not(feature = "__tests"))] { unreachable!() } @@ -600,12 +600,12 @@ mod utils { } fn scheme(&self) -> &norm::fzf::Scheme { - #[cfg(feature = "tests")] + #[cfg(feature = "__tests")] { self.scheme() } - #[cfg(not(feature = "tests"))] + #[cfg(not(feature = "__tests"))] { unreachable!() }