@@ -1008,7 +1008,7 @@ impl TableCollection {
1008
1008
handle_tsk_return_value ! ( rv)
1009
1009
}
1010
1010
1011
- /// Set the individual table from an [`OwnedMutationTable `](`crate::OwnedSiteTable`)
1011
+ /// Set the individual table from an [`OwnedIndividualTable `](`crate::OwnedSiteTable`)
1012
1012
///
1013
1013
/// # Errors
1014
1014
///
@@ -1024,7 +1024,7 @@ impl TableCollection {
1024
1024
/// tables.set_individuals(&individuals).unwrap();
1025
1025
/// assert_eq!(tables.individuals().num_rows(), 1);
1026
1026
/// let expected = vec![tskit::Location::from(0.1), tskit::Location::from(10.0)];
1027
- /// assert_eq!(tables.individuals().location(0).unwrap(), Some(expected));
1027
+ /// assert_eq!(tables.individuals().location(0).unwrap(), Some(expected.as_slice() ));
1028
1028
/// # individuals.clear().unwrap();
1029
1029
/// # assert_eq!(individuals.num_rows(), 0);
1030
1030
/// ```
@@ -1047,7 +1047,43 @@ impl TableCollection {
1047
1047
handle_tsk_return_value ! ( rv)
1048
1048
}
1049
1049
1050
- pub fn set_migrations ( & mut self , migrations : & crate :: OwnedMigrationTable ) -> TskReturnValue { }
1050
+
1051
+ /// Set the migration table from an [`OwnedMigrationTable`](`crate::OwnedSiteTable`)
1052
+ ///
1053
+ /// # Errors
1054
+ ///
1055
+ /// Any errors from the C API propagate.
1056
+ ///
1057
+ /// # Example
1058
+ ///
1059
+ /// ```rust
1060
+ /// # use tskit::TableAccess;
1061
+ /// let mut tables = tskit::TableCollection::new(1.0).unwrap();
1062
+ /// let mut migrations = tskit::OwnedMigrationTable::default();
1063
+ /// migrations.add_row((0.25, 0.37), 1, (0, 1), 111.0).unwrap();
1064
+ /// tables.set_migrations(&migrations).unwrap();
1065
+ /// assert_eq!(tables.migrations().num_rows(), 1);
1066
+ /// assert_eq!(tables.migrations().time(0).unwrap(), 111.0);
1067
+ /// # migrations.clear().unwrap();
1068
+ /// # assert_eq!(migrations.num_rows(), 0);
1069
+ /// ```
1070
+ pub fn set_migrations ( & mut self , migrations : & crate :: OwnedMigrationTable ) -> TskReturnValue {
1071
+ let rv = unsafe {
1072
+ ll_bindings:: tsk_migration_table_set_columns (
1073
+ & mut ( * self . inner ) . migrations ,
1074
+ ( * migrations. as_ptr ( ) ) . num_rows ,
1075
+ ( * migrations. as_ptr ( ) ) . left ,
1076
+ ( * migrations. as_ptr ( ) ) . right ,
1077
+ ( * migrations. as_ptr ( ) ) . node ,
1078
+ ( * migrations. as_ptr ( ) ) . source ,
1079
+ ( * migrations. as_ptr ( ) ) . dest ,
1080
+ ( * migrations. as_ptr ( ) ) . time ,
1081
+ ( * migrations. as_ptr ( ) ) . metadata ,
1082
+ ( * migrations. as_ptr ( ) ) . metadata_offset ,
1083
+ )
1084
+ } ;
1085
+ handle_tsk_return_value ! ( rv)
1086
+ }
1051
1087
}
1052
1088
1053
1089
impl TableAccess for TableCollection {
0 commit comments