Skip to content

Commit

Permalink
feat: check for field index
Browse files Browse the repository at this point in the history
  • Loading branch information
JakkuSakura committed May 20, 2024
1 parent 06e113c commit f849b78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/worktable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,12 @@ impl WorkTable {
}
//noinspection RsConstantConditionIf
pub fn add_field<T: WorkTableField>(&mut self, _field: T) {
self.add_column(T::NAME, <T::Type as IntoColumn>::into_column());
let name = T::NAME.to_string();
let index = self.column_names.len();
assert_eq!(index, T::INDEX, "Field index mismatch");
self.columns_map.insert(name.clone(), index as _);
self.column_names.push(name);
self.column_values.push(T::Type::into_column());

if T::PRIMARY {
self.set_primary();
Expand Down

0 comments on commit f849b78

Please sign in to comment.