From 49a763cd619b234471ac30adf4e3fdf3e22e89d1 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 27 Jul 2021 17:48:13 +0100 Subject: [PATCH] Rename `Table::assign_fixed` to `Table::assign_cell` --- examples/circuit-layout.rs | 4 ++-- src/circuit.rs | 8 +++++--- src/circuit/floor_planner/single_pass.rs | 2 +- src/circuit/layouter.rs | 6 ++++-- tests/plonk_api.rs | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/circuit-layout.rs b/examples/circuit-layout.rs index 944e62d6..e8bd532e 100644 --- a/examples/circuit-layout.rs +++ b/examples/circuit-layout.rs @@ -173,9 +173,9 @@ fn main() { ) -> Result<(), Error> { layouter.assign_table( || "", - |mut region| { + |mut table| { for (index, &value) in values.iter().enumerate() { - region.assign_fixed(|| "table col", self.config.sl, index, || Ok(value))?; + table.assign_cell(|| "table col", self.config.sl, index, || Ok(value))?; } Ok(()) }, diff --git a/src/circuit.rs b/src/circuit.rs index fad4b07d..f49d5b7f 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -257,10 +257,12 @@ impl<'r, F: Field> From<&'r mut dyn layouter::TableLayouter> for Table<'r, F> } impl<'r, F: Field> Table<'r, F> { - /// Assign a fixed value. + /// Assigns a fixed value to a table cell. + /// + /// Returns an error if the table cell has already been assigned to. /// /// Even though `to` has `FnMut` bounds, it is guaranteed to be called at most once. - pub fn assign_fixed<'v, V, VR, A, AR>( + pub fn assign_cell<'v, V, VR, A, AR>( &'v mut self, annotation: A, column: TableColumn, @@ -274,7 +276,7 @@ impl<'r, F: Field> Table<'r, F> { AR: Into, { self.table - .assign_fixed(&|| annotation().into(), column, offset, &mut || { + .assign_cell(&|| annotation().into(), column, offset, &mut || { to().map(|v| v.into()) }) } diff --git a/src/circuit/floor_planner/single_pass.rs b/src/circuit/floor_planner/single_pass.rs index bb6b8bfa..5bffd777 100644 --- a/src/circuit/floor_planner/single_pass.rs +++ b/src/circuit/floor_planner/single_pass.rs @@ -407,7 +407,7 @@ impl<'r, 'a, F: Field, CS: Assignment + 'a> SimpleTableLayouter<'r, 'a, F, CS impl<'r, 'a, F: Field, CS: Assignment + 'a> TableLayouter for SimpleTableLayouter<'r, 'a, F, CS> { - fn assign_fixed<'v>( + fn assign_cell<'v>( &'v mut self, annotation: &'v (dyn Fn() -> String + 'v), column: TableColumn, diff --git a/src/circuit/layouter.rs b/src/circuit/layouter.rs index 1aa5a42a..9f249d4c 100644 --- a/src/circuit/layouter.rs +++ b/src/circuit/layouter.rs @@ -110,8 +110,10 @@ pub trait RegionLayouter: fmt::Debug { /// /// [`Layouter`]: super::Layouter pub trait TableLayouter: fmt::Debug { - /// Assign a fixed value - fn assign_fixed<'v>( + /// Assigns a fixed value to a table cell. + /// + /// Returns an error if the table cell has already been assigned to. + fn assign_cell<'v>( &'v mut self, annotation: &'v (dyn Fn() -> String + 'v), column: TableColumn, diff --git a/tests/plonk_api.rs b/tests/plonk_api.rs index 11df30bf..4b986b36 100644 --- a/tests/plonk_api.rs +++ b/tests/plonk_api.rs @@ -232,7 +232,7 @@ fn plonk_api() { || "", |mut table| { for (index, &value) in values.iter().enumerate() { - table.assign_fixed(|| "table col", self.config.sl, index, || Ok(value))?; + table.assign_cell(|| "table col", self.config.sl, index, || Ok(value))?; } Ok(()) },