Lines
100 %
Functions
Branches
use forms::{Form, FormValues, drop_orphans};
/// Copies the nested rows fields `form` has from `from` into `to`, keeping a
/// present empty field present and a missing one missing, then drops the rows
/// whose parent row is not in `to`.
pub fn copy_carried(form: &Form, from: &FormValues, to: &mut FormValues) {
copy_rows(form, from, to);
drop_orphans(form, to);
}
fn copy_rows(form: &Form, from: &FormValues, to: &mut FormValues) {
for key in form.nested_keys() {
let Some(rows) = from.rows(key) else {
continue;
};
to.set_rows(key);
rows.iter().for_each(|row| to.push_row(key, row.clone()));