Skip to content

Commit

Permalink
Fix edge case of --no-default-features --features json.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grinkers committed Dec 19, 2023
1 parent 3ab792e commit 43d9af6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ jobs:
with:
components: clippy
- run: cargo clippy --all-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings
- run: cargo clippy --features json --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings
- run: cargo clippy --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tests:

clippy:
cargo clippy --all-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings
cargo clippy --features json --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings
cargo clippy --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings

fmt:
Expand Down
16 changes: 9 additions & 7 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
{clean {:doc "Removes target folder"
:requires ([babashka.fs :as fs])
:task (fs/delete-tree "target")}

test_lib_features (shell "cargo test --all-features --no-fail-fast")
test_lib_no_default_features (shell "cargo test --no-default-features --no-fail-fast")
example_fast (shell "cargo test --examples --no-fail-fast")
example_json_to_edn (shell "cargo test --example json_to_edn --features \"json\"")
example_edn_to_json (shell "cargo test --example edn_to_json --features \"json\"")
example_async (shell "cargo run --example async")
example_no_sets (shell "cargo run --example struct_from_str --no-default-features")

cargo-test {:doc "Runs all cargo tests"
:depends [test_lib_features test_lib_no_default_features example_fast
example_json_to_edn example_edn_to_json example_edn_to_json
example_async example_no_sets]}
cargo-fmt {:doc "Checks cargo fmt"
:task (shell "cargo fmt --check")}
cargo-clippy {:doc "Runs cargo clippy"
:task (do
(shell "cargo clippy --all-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings")
(shell "cargo clippy --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings"))}
cargo-clippy-all-features {:doc "Cargo clippy with all features"
:task (shell "cargo clippy --all-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings")}
cargo-clippy-no-sets-json {:doc "Cargo clippy with json feature but no default features"
:task (shell "cargo clippy --features json --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings")}
cargo-clippy-no-defaults {:doc "Cargo clippy with no default features"
:task (shell "cargo clippy --features json --no-default-features -- -W future-incompatible -W rust_2018_idioms -W clippy::all -W clippy::pedantic -W clippy::nursery --deny warnings")}
clippy {:doc "Runs all variations of cargo clippy"
:depends [cargo-clippy-all-features cargo-clippy-no-sets-json cargo-clippy-no-defaults]}
test {:doc "Runs all tests and checks"
:depends [cargo-test cargo-fmt cargo-clippy]}}}
:depends [cargo-test cargo-fmt clippy]}}}
2 changes: 2 additions & 0 deletions src/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::edn::{rational_to_double, Edn};
pub fn display_as_json(edn: &Edn) -> String {
match edn {
Edn::Vector(v) => vec_to_json(&v.clone().to_vec()),
#[cfg(feature = "sets")]
Edn::Set(s) => set_to_json_vec(&s.clone().to_set()),
Edn::Map(map) => map_to_json(&map.clone().to_map()),
Edn::List(l) => vec_to_json(&l.clone().to_vec()),
Expand Down Expand Up @@ -68,6 +69,7 @@ fn vec_to_json(vec: &[Edn]) -> String {
s
}

#[cfg(feature = "sets")]
fn set_to_json_vec(set: &std::collections::BTreeSet<Edn>) -> String {
let set_str = set
.iter()
Expand Down

0 comments on commit 43d9af6

Please sign in to comment.