Rename `Table::assign_fixed` to `Table::assign_cell`

This commit is contained in:
Jack Grigg 2021-07-27 17:48:13 +01:00
parent a62c5d13fd
commit 49a763cd61
5 changed files with 13 additions and 9 deletions

View File

@ -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(())
},

View File

@ -257,10 +257,12 @@ impl<'r, F: Field> From<&'r mut dyn layouter::TableLayouter<F>> 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<String>,
{
self.table
.assign_fixed(&|| annotation().into(), column, offset, &mut || {
.assign_cell(&|| annotation().into(), column, offset, &mut || {
to().map(|v| v.into())
})
}

View File

@ -407,7 +407,7 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> SimpleTableLayouter<'r, 'a, F, CS
impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> TableLayouter<F>
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,

View File

@ -110,8 +110,10 @@ pub trait RegionLayouter<F: Field>: fmt::Debug {
///
/// [`Layouter`]: super::Layouter
pub trait TableLayouter<F: Field>: 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,

View File

@ -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(())
},