@@ -583,7 +583,7 @@ impl TableCollection {
583583 Some ( unsafe {
584584 std:: slice:: from_raw_parts (
585585 ( * self . as_ptr ( ) ) . indexes . edge_insertion_order as * const EdgeId ,
586- crate :: util :: handle_u64_to_usize ( ( * self . as_ptr ( ) ) . indexes . num_edges ) ,
586+ usize :: try_from ( ( * self . as_ptr ( ) ) . indexes . num_edges ) . unwrap ( ) ,
587587 )
588588 } )
589589 } else {
@@ -599,7 +599,7 @@ impl TableCollection {
599599 Some ( unsafe {
600600 std:: slice:: from_raw_parts (
601601 ( * self . as_ptr ( ) ) . indexes . edge_removal_order as * const EdgeId ,
602- crate :: util :: handle_u64_to_usize ( ( * self . as_ptr ( ) ) . indexes . num_edges ) ,
602+ usize :: try_from ( ( * self . as_ptr ( ) ) . indexes . num_edges ) . unwrap ( ) ,
603603 )
604604 } )
605605 } else {
@@ -798,7 +798,7 @@ impl TableCollection {
798798 ) -> Result < Option < Vec < NodeId > > , TskitError > {
799799 let mut output_node_map: Vec < NodeId > = vec ! [ ] ;
800800 if idmap {
801- output_node_map. resize ( usize:: from ( self . nodes ( ) . num_rows ( ) ) , NodeId :: NULL ) ;
801+ output_node_map. resize ( usize:: try_from ( self . nodes ( ) . num_rows ( ) ) ? , NodeId :: NULL ) ;
802802 }
803803 let rv = unsafe {
804804 ll_bindings:: tsk_table_collection_simplify (
@@ -1105,11 +1105,11 @@ mod test {
11051105 assert ! ( tables. is_indexed( ) ) ;
11061106 assert_eq ! (
11071107 tables. edge_insertion_order( ) . unwrap( ) . len( ) ,
1108- tables. edges( ) . num_rows( ) . into ( )
1108+ tables. edges( ) . num_rows( ) . try_into ( ) . unwrap ( )
11091109 ) ;
11101110 assert_eq ! (
11111111 tables. edge_removal_order( ) . unwrap( ) . len( ) ,
1112- tables. edges( ) . num_rows( ) . into ( )
1112+ tables. edges( ) . num_rows( ) . try_into ( ) . unwrap ( )
11131113 ) ;
11141114
11151115 for i in tables. edge_insertion_order ( ) . unwrap ( ) {
@@ -1362,7 +1362,7 @@ mod test {
13621362
13631363 let mut num_with_metadata = 0 ;
13641364 let mut num_without_metadata = 0 ;
1365- for i in 0 ..usize:: from ( tables. mutations ( ) . num_rows ( ) ) {
1365+ for i in 0 ..usize:: try_from ( tables. mutations ( ) . num_rows ( ) ) . unwrap ( ) {
13661366 match tables
13671367 . mutations ( )
13681368 . metadata :: < F > ( ( i as tsk_id_t ) . into ( ) )
@@ -1837,7 +1837,7 @@ mod test_adding_site {
18371837 Some ( metadata[ mi] )
18381838 ) ;
18391839 }
1840- for i in 0 ..usize:: from ( tables. sites ( ) . num_rows ( ) ) {
1840+ for i in 0 ..usize:: try_from ( tables. sites ( ) . num_rows ( ) ) . unwrap ( ) {
18411841 assert ! (
18421842 tables. sites( ) . row( SiteId :: from( i as tsk_id_t) ) . unwrap( )
18431843 == tables. sites( ) . row( SiteId :: from( i as tsk_id_t) ) . unwrap( )
0 commit comments