@@ -84,7 +84,7 @@ pub trait Graph<H: Hasher>: ::std::fmt::Debug + Clone + PartialEq + Eq {
8484 ///
8585 /// The `parents` parameter is used to store the result. This is done fore performance
8686 /// reasons, so that the vector can be allocated outside this call.
87- fn parents ( & self , node : usize , parents : & mut [ usize ] ) ;
87+ fn parents ( & self , node : usize , parents : & mut [ u32 ] ) ;
8888
8989 /// Returns the size of the graph (number of nodes).
9090 fn size ( & self ) -> usize ;
@@ -101,7 +101,7 @@ pub trait Graph<H: Hasher>: ::std::fmt::Debug + Clone + PartialEq + Eq {
101101 & self ,
102102 id : & H :: Domain ,
103103 node : usize ,
104- parents : & [ usize ] ,
104+ parents : & [ u32 ] ,
105105 parents_data : & [ u8 ] ,
106106 exp_parents_data : Option < & [ u8 ] > ,
107107 ) -> Result < Self :: Key > ;
@@ -143,17 +143,17 @@ impl<H: Hasher> Graph<H> for BucketGraph<H> {
143143 & self ,
144144 id : & H :: Domain ,
145145 node : usize ,
146- parents : & [ usize ] ,
146+ parents : & [ u32 ] ,
147147 base_parents_data : & [ u8 ] ,
148148 _exp_parents_data : Option < & [ u8 ] > ,
149149 ) -> Result < Self :: Key > {
150150 let mut hasher = Blake2s :: new ( ) . hash_length ( NODE_SIZE ) . to_state ( ) ;
151151 hasher. update ( AsRef :: < [ u8 ] > :: as_ref ( id) ) ;
152152
153153 // The hash is about the parents, hence skip if a node doesn't have any parents
154- if node != parents[ 0 ] {
154+ if node != parents[ 0 ] as usize {
155155 for parent in parents. iter ( ) {
156- let offset = data_at_node_offset ( * parent) ;
156+ let offset = data_at_node_offset ( * parent as usize ) ;
157157 hasher. update ( & base_parents_data[ offset..offset + NODE_SIZE ] ) ;
158158 }
159159 }
@@ -163,7 +163,7 @@ impl<H: Hasher> Graph<H> for BucketGraph<H> {
163163 }
164164
165165 #[ inline]
166- fn parents ( & self , node : usize , parents : & mut [ usize ] ) {
166+ fn parents ( & self , node : usize , parents : & mut [ u32 ] ) {
167167 let m = self . degree ( ) ;
168168
169169 match node {
@@ -198,15 +198,15 @@ impl<H: Hasher> Graph<H> for BucketGraph<H> {
198198
199199 // remove self references and replace with reference to previous node
200200 if out == node {
201- * parent = node - 1 ;
201+ * parent = ( node - 1 ) as u32 ;
202202 } else {
203203 assert ! ( out <= node) ;
204- * parent = out;
204+ * parent = out as u32 ;
205205 }
206206 }
207207
208208 // Add the immediate predecessor as a parent to ensure unique topological ordering.
209- parents[ m_prime] = node - 1 ;
209+ parents[ m_prime] = ( node - 1 ) as u32 ;
210210 }
211211 }
212212 }
@@ -297,7 +297,7 @@ mod tests {
297297
298298 for parent in p1 {
299299 // TODO: fix me
300- assert_ne ! ( i, parent, "self reference found" ) ;
300+ assert_ne ! ( i, parent as usize , "self reference found" ) ;
301301 }
302302 }
303303 }
0 commit comments