diff --git a/src/jsonpath.rs b/src/jsonpath.rs index e65c958..72a7ce8 100644 --- a/src/jsonpath.rs +++ b/src/jsonpath.rs @@ -18,6 +18,6 @@ impl std::fmt::Display for SyntaxError { } } -pub fn parse(selector: &str) -> Result, SyntaxError> { +pub fn parse(selector: &str) -> Result { parser::parse(selector).map_err(|m| SyntaxError { message: m }) } diff --git a/src/parser.rs b/src/parser.rs index 7096728..a5843d0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -12,7 +12,7 @@ use crate::pest::Parser; #[grammar = "grammar.pest"] struct PathParser; -pub fn parse(selector: &str) -> Result, String> { +pub fn parse(selector: &str) -> Result { let selector_rule = PathParser::parse(Rule::selector, selector) .map_err(|e| format!("{}", e))? .next() @@ -33,7 +33,7 @@ pub fn parse(selector: &str) -> Result, String> { } } - Ok(Box::new(path::new(ms))) + Ok(path::new(ms)) } fn parse_matcher(matcher_rule: pest::iterators::Pair) -> Vec> { diff --git a/tests/cts.rs b/tests/cts.rs index 30b5de9..166fe55 100644 --- a/tests/cts.rs +++ b/tests/cts.rs @@ -6,7 +6,7 @@ #[cfg(test)] mod tests { - use jsonpath_reference_implementation::jsonpath; + use jsonpath_reference_implementation::{jsonpath, path::Path as _}; use serde::{Deserialize, Serialize}; use std::fs; use std::panic;