Skip to main content

diff_rows

Function diff_rows 

Source
pub fn diff_rows(
    old_rows: &[RowSet],
    new_rows: &[RowSet],
) -> GuiResult<RowDelta>
Expand description

Classifies new_rows against old_rows without touching either.

Duplicate keys in new_rows are rejected with GuiError::Backend("duplicate row key") and nothing is classified; the caller keeps its previous rows and selection.

use native_gui_core::widgets::{diff_rows, RowDelta, RowSet};

let old = [RowSet::new(1, &["a"]), RowSet::new(2, &["b"])];
let new = [RowSet::new(2, &["b"]), RowSet::new(3, &["c"])];
let delta = diff_rows(&old, &new).expect("unique keys");
assert_eq!(delta, RowDelta { inserted: 1, updated: 0, removed: 1, moved: 1, unchanged: 0 });
assert!(!delta.is_noop());