Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 31c6896

Browse files
authored
Merge pull request #16 from mkmik/cleanupparse
Avoid using dyn Path when not necessary
2 parents eafdf74 + bebe612 commit 31c6896

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/jsonpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ impl std::fmt::Display for SyntaxError {
1818
}
1919
}
2020

21-
pub fn parse(selector: &str) -> Result<Box<dyn Path + '_>, SyntaxError> {
21+
pub fn parse(selector: &str) -> Result<impl Path, SyntaxError> {
2222
parser::parse(selector).map_err(|m| SyntaxError { message: m })
2323
}

src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::pest::Parser;
1212
#[grammar = "grammar.pest"]
1313
struct PathParser;
1414

15-
pub fn parse(selector: &str) -> Result<Box<dyn path::Path + '_>, String> {
15+
pub fn parse(selector: &str) -> Result<impl path::Path, String> {
1616
let selector_rule = PathParser::parse(Rule::selector, selector)
1717
.map_err(|e| format!("{}", e))?
1818
.next()
@@ -33,7 +33,7 @@ pub fn parse(selector: &str) -> Result<Box<dyn path::Path + '_>, String> {
3333
}
3434
}
3535

36-
Ok(Box::new(path::new(ms)))
36+
Ok(path::new(ms))
3737
}
3838

3939
fn parse_matcher(matcher_rule: pest::iterators::Pair<Rule>) -> Vec<Box<dyn matchers::Matcher>> {

tests/cts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#[cfg(test)]
88
mod tests {
9-
use jsonpath_reference_implementation::jsonpath;
9+
use jsonpath_reference_implementation::{jsonpath, path::Path as _};
1010
use serde::{Deserialize, Serialize};
1111
use std::fs;
1212
use std::panic;

0 commit comments

Comments
 (0)