File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1029,6 +1029,11 @@ where
10291029 i
10301030 }
10311031 fn from_index ( & self , ix : usize ) -> Self :: NodeId {
1032+ assert ! (
1033+ ix < self . nodes. len( ) ,
1034+ "The requested index {} is out-of-bounds." ,
1035+ ix
1036+ ) ;
10321037 let ( & key, _) = self . nodes . get_index ( ix) . unwrap ( ) ;
10331038 key
10341039 }
@@ -1056,6 +1061,11 @@ where
10561061 }
10571062
10581063 fn from_index ( & self , ix : usize ) -> Self :: EdgeId {
1064+ assert ! (
1065+ ix < self . edges. len( ) ,
1066+ "The requested index {} is out-of-bounds." ,
1067+ ix
1068+ ) ;
10591069 let ( & key, _) = self . edges . get_index ( ix) . unwrap ( ) ;
10601070 key
10611071 }
Original file line number Diff line number Diff line change @@ -508,7 +508,7 @@ trait_template! {
508508 fn node_bound( self : & Self ) -> usize ;
509509 /// Convert `a` to an integer index.
510510 fn to_index( self : & Self , a: Self :: NodeId ) -> usize ;
511- /// Convert `i` to a node index
511+ /// Convert `i` to a node index. `i` must be a valid value in the graph.
512512 fn from_index( self : & Self , i: usize ) -> Self :: NodeId ;
513513 }
514514}
@@ -524,7 +524,7 @@ trait_template! {
524524 fn edge_bound( self : & Self ) -> usize ;
525525 /// Convert `a` to an integer index.
526526 fn to_index( self : & Self , a: Self :: EdgeId ) -> usize ;
527- /// Convert `i` to a node index
527+ /// Convert `i` to an edge index. `i` must be a valid value in the graph.
528528 fn from_index( self : & Self , i: usize ) -> Self :: EdgeId ;
529529 }
530530}
You can’t perform that action at this time.
0 commit comments