@@ -1047,7 +1047,6 @@ impl TableCollection {
1047
1047
handle_tsk_return_value ! ( rv)
1048
1048
}
1049
1049
1050
-
1051
1050
/// Set the migration table from an [`OwnedMigrationTable`](`crate::OwnedSiteTable`)
1052
1051
///
1053
1052
/// # Errors
@@ -1084,6 +1083,36 @@ impl TableCollection {
1084
1083
} ;
1085
1084
handle_tsk_return_value ! ( rv)
1086
1085
}
1086
+
1087
+ /// Set the population table from an [`OwnedPopulationTable`](`crate::OwnedSiteTable`)
1088
+ ///
1089
+ /// # Errors
1090
+ ///
1091
+ /// Any errors from the C API propagate.
1092
+ ///
1093
+ /// # Example
1094
+ ///
1095
+ /// ```rust
1096
+ /// # use tskit::TableAccess;
1097
+ /// let mut tables = tskit::TableCollection::new(1.0).unwrap();
1098
+ /// let mut populations = tskit::OwnedPopulationTable::default();
1099
+ /// populations.add_row().unwrap();
1100
+ /// tables.set_populations(&populations).unwrap();
1101
+ /// assert_eq!(tables.populations().num_rows(), 1);
1102
+ /// # populations.clear().unwrap();
1103
+ /// # assert_eq!(populations.num_rows(), 0);
1104
+ /// ```
1105
+ pub fn set_populations ( & mut self , populations : & crate :: OwnedPopulationTable ) -> TskReturnValue {
1106
+ let rv = unsafe {
1107
+ ll_bindings:: tsk_population_table_set_columns (
1108
+ & mut ( * self . inner ) . populations ,
1109
+ ( * populations. as_ptr ( ) ) . num_rows ,
1110
+ ( * populations. as_ptr ( ) ) . metadata ,
1111
+ ( * populations. as_ptr ( ) ) . metadata_offset ,
1112
+ )
1113
+ } ;
1114
+ handle_tsk_return_value ! ( rv)
1115
+ }
1087
1116
}
1088
1117
1089
1118
impl TableAccess for TableCollection {
0 commit comments