Skip to content

Commit

Permalink
Make dehydrate Options a mutable ref.
Browse files Browse the repository at this point in the history
Otherwise it is not possible to reuse the same generator across multiple
dehydration calls.
  • Loading branch information
cobward committed Dec 13, 2023
1 parent 43fcf93 commit 6ce1195
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions layouts/src/distill/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<G> Options<G> {
/// &layouts,
/// &value,
/// &layout_ref,
/// treeldr_layouts::distill::de::Options::default()
/// &mut treeldr_layouts::distill::de::Options::default()
/// ).unwrap();
///
/// // The number of subjects is equal to the number of layout inputs.
Expand Down Expand Up @@ -231,7 +231,7 @@ pub fn dehydrate<G: Generator>(
layouts: &Layouts,
value: &Value,
layout_ref: &Ref<LayoutType>,
mut options: Options<G>,
options: &mut Options<G>,
) -> Result<(BTreeDataset<Term>, Vec<Term>), Error> {
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
enum InputResource {
Expand Down Expand Up @@ -447,16 +447,16 @@ pub fn dehydrate<G: Generator>(
.into_iter()
.map(|quad| {
Quad(
map_resource(&mut map, quad.0, &mut options),
map_resource(&mut map, quad.1, &mut options),
map_resource(&mut map, quad.2, &mut options),
quad.3.map(|g| map_resource(&mut map, g, &mut options)),
map_resource(&mut map, quad.0, options),
map_resource(&mut map, quad.1, options),
map_resource(&mut map, quad.2, options),
quad.3.map(|g| map_resource(&mut map, g, options)),
)
})
.collect();

let values = (0..input_count)
.map(|i| map_resource(&mut map, InputResource::Input(i), &mut options))
.map(|i| map_resource(&mut map, InputResource::Input(i), options))
.collect();

Ok((dataset, values))
Expand Down
2 changes: 1 addition & 1 deletion layouts/tests/distill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn dehydrate<const N: usize>(id: &str, expected_values: [Term; N]) {
&layouts,
&input,
&layout_ref,
treeldr_layouts::distill::de::Options::default()
&mut treeldr_layouts::distill::de::Options::default()
.with_input_count(expected_values.len() as u32),
)
.unwrap();
Expand Down

0 comments on commit 6ce1195

Please sign in to comment.