move lifetime to result

lifetime should be on the Vec<&'a Value> and not on the input
This commit is contained in:
Guy Korland 2019-07-31 16:22:35 +03:00 committed by GitHub
parent c0a5296451
commit d9b9e9d8bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,7 +214,7 @@ pub fn compile(path: &str) -> impl FnMut(&Value) -> Result<Vec<&Value>, JsonPath
/// ]); /// ]);
/// ``` /// ```
#[allow(clippy::needless_lifetimes)] #[allow(clippy::needless_lifetimes)]
pub fn selector<'a>(json: &'a Value) -> impl FnMut(&'a str) -> Result<Vec<&Value>, JsonPathError> { pub fn selector<'a>(json: &'a Value) -> impl FnMut(&str) -> Result<Vec<&'a Value>, JsonPathError> {
let mut selector = Selector::default(); let mut selector = Selector::default();
let _ = selector.value(json); let _ = selector.value(json);
move |path: &str| selector.str_path(path)?.reset_value().select() move |path: &str| selector.str_path(path)?.reset_value().select()