Skip to content

Commit de1ad88

Browse files
authored
Merge branch 'main' into chore/toolchain-update
2 parents e58c0da + 2c67ac5 commit de1ad88

File tree

4 files changed

+194
-195
lines changed

4 files changed

+194
-195
lines changed

Cargo.lock

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/jit/fixtures/jp.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::core::jit::builder::Builder;
88
use crate::core::jit::store::Store;
99
use crate::core::jit::synth::Synth;
1010
use crate::core::jit::transform::InputResolver;
11-
use crate::core::jit::{transform, OperationPlan, Variables};
11+
use crate::core::jit::{transform, Field, OperationPlan, Variables};
1212
use crate::core::json::{JsonLike, JsonObjectLike};
1313
use crate::core::valid::Validator;
1414
use crate::core::Transform;
@@ -119,10 +119,11 @@ impl<'a, Value: Deserialize<'a> + Clone + 'a + JsonLike<'a> + std::fmt::Debug> J
119119
let ProcessedTestData { posts, users } = self.test_data.to_processed();
120120
let vars = self.vars.clone();
121121

122-
let posts_id = self.plan.find_field_path(&["posts"]).unwrap().id.to_owned();
123-
let users_id = self
124-
.plan
125-
.find_field_path(&["posts", "user"])
122+
let posts_id = find_field_path(&self.plan, &["posts"])
123+
.unwrap()
124+
.id
125+
.to_owned();
126+
let users_id = find_field_path(&self.plan, &["posts", "user"])
126127
.unwrap()
127128
.id
128129
.to_owned();
@@ -137,3 +138,21 @@ impl<'a, Value: Deserialize<'a> + Clone + 'a + JsonLike<'a> + std::fmt::Debug> J
137138
Synth::new(&self.plan, store, vars)
138139
}
139140
}
141+
142+
/// Search for a field by specified path of nested fields
143+
pub fn find_field_path<'a, S: AsRef<str>, T>(
144+
plan: &'a OperationPlan<T>,
145+
path: &[S],
146+
) -> Option<&'a Field<T>> {
147+
match path.split_first() {
148+
None => None,
149+
Some((name, path)) => {
150+
let field = plan.iter_dfs().find(|field| field.name == name.as_ref())?;
151+
if path.is_empty() {
152+
Some(field)
153+
} else {
154+
find_field_path(plan, path)
155+
}
156+
}
157+
}
158+
}

src/core/jit/model.rs

-15
Original file line numberDiff line numberDiff line change
@@ -366,21 +366,6 @@ impl<Input> OperationPlan<Input> {
366366
DFS { stack: vec![self.selection.iter()] }
367367
}
368368

369-
/// Search for a field by specified path of nested fields
370-
pub fn find_field_path<S: AsRef<str>>(&self, path: &[S]) -> Option<&Field<Input>> {
371-
match path.split_first() {
372-
None => None,
373-
Some((name, path)) => {
374-
let field = self.iter_dfs().find(|field| field.name == name.as_ref())?;
375-
if path.is_empty() {
376-
Some(field)
377-
} else {
378-
self.find_field_path(path)
379-
}
380-
}
381-
}
382-
}
383-
384369
/// Returns number of fields in plan
385370
pub fn size(&self) -> usize {
386371
fn count<A>(field: &Field<A>) -> usize {

0 commit comments

Comments
 (0)