Skip to content

Commit

Permalink
provide a minimal example code, fix clippy issues and harden CI to ve…
Browse files Browse the repository at this point in the history
…rify everything
  • Loading branch information
xMAC94x committed Jun 10, 2024
1 parent 6b243d6 commit 4238e91
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
profile: minimal
toolchain: stable
components: clippy
- run: cargo clippy --workspace --tests --all-features -- -D warnings
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings

test:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions benches/equal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct SearchData {
path: JsonPathInst,
}

const PATH: &'static str = "$.[?(@.author == 'abcd(Rees)')]";
const PATH: &str = "$.[?(@.author == 'abcd(Rees)')]";

fn equal_perf_test_with_reuse(cfg: &SearchData) {
let _v = jsonpath_rust::find(&cfg.path, &cfg.json);
Expand All @@ -33,7 +33,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
b.iter(|| equal_perf_test_with_reuse(&data))
});
c.bench_function("equal bench without reuse", |b| {
b.iter(|| equal_perf_test_without_reuse())
b.iter(equal_perf_test_without_reuse)
});
}

Expand Down
6 changes: 3 additions & 3 deletions benches/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct SearchData {
path: JsonPathInst,
}

const PATH: &'static str = "$.[?(@.author ~= '.*(?i)d\\(Rees\\)')]";
const PATH: &str = "$.[?(@.author ~= '.*(?i)d\\(Rees\\)')]";

fn regex_perf_test_with_reuse(cfg: &SearchData) {
let _v = jsonpath_rust::find(&cfg.path, &cfg.json);
Expand Down Expand Up @@ -37,10 +37,10 @@ pub fn criterion_benchmark(c: &mut Criterion) {
b.iter(|| regex_perf_test_with_reuse(&data))
});
c.bench_function("regex bench without reuse", |b| {
b.iter(|| regex_perf_test_without_reuse())
b.iter(regex_perf_test_without_reuse)
});
c.bench_function("JsonPathInst generation", |b| {
b.iter(|| json_path_inst_compiling())
b.iter(json_path_inst_compiling)
});
}

Expand Down
13 changes: 13 additions & 0 deletions examples/hello-world.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use jsonpath_rust::JsonPathInst;
use serde_json::json;
use std::str::FromStr;

fn main() {
let data = json!({
"Hello":"World",
"Good":"Bye",
});
let path = JsonPathInst::from_str("$.Hello").unwrap();
let search_result = jsonpath_rust::find(&path, &data);
println!("Hello, {}", search_result);
}
2 changes: 2 additions & 0 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::empty_docs)]

use crate::parser::errors::JsonPathParserError::ParserError;
use crate::parser::errors::{parser_err, JsonPathParserError};
use crate::parser::model::FilterExpression::{And, Not, Or};
Expand Down

0 comments on commit 4238e91

Please sign in to comment.