@@ -216,14 +216,14 @@ impl ObjectRef {
216
216
217
217
218
218
pub struct ObjectStore {
219
- all_objects : HashMap < ObjectRef , Object > ,
219
+ all_objects : HashMap < usize , Object > ,
220
220
}
221
221
222
222
impl fmt:: Debug for ObjectStore {
223
223
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
224
224
try!( write ! ( f, "ObjectStore {{ all_objects: HashMap {{\n " ) ) ;
225
- for ( ref obj_ref , ref obj) in self . all_objects . iter ( ) {
226
- try!( write ! ( f, "\t {} => {:?}\n " , obj_ref . id, obj) ) ;
225
+ for ( ref id , ref obj) in self . all_objects . iter ( ) {
226
+ try!( write ! ( f, "\t {} => {:?}\n " , id, obj) ) ;
227
227
}
228
228
write ! ( f, "}}}}\n " )
229
229
}
@@ -236,24 +236,24 @@ impl ObjectStore {
236
236
237
237
pub fn allocate ( & mut self , obj : Object ) -> ObjectRef {
238
238
let obj_ref = ObjectRef :: new ( ) ;
239
- self . all_objects . insert ( obj_ref. clone ( ) , obj) ;
239
+ self . all_objects . insert ( obj_ref. id . clone ( ) , obj) ;
240
240
obj_ref
241
241
}
242
242
243
243
pub fn allocate_at ( & mut self , obj_ref : ObjectRef , obj : Object ) {
244
- match self . all_objects . get ( & obj_ref) {
245
- None => self . all_objects . insert ( obj_ref, obj) ,
244
+ match self . all_objects . get ( & obj_ref. id ) {
245
+ None => self . all_objects . insert ( obj_ref. id , obj) ,
246
246
_ => panic ! ( "Already allocated" ) ,
247
247
} ;
248
248
}
249
249
250
250
pub fn deref ( & self , obj_ref : & ObjectRef ) -> & Object {
251
251
// TODO: check the reference is valid
252
- self . all_objects . get ( obj_ref) . unwrap ( )
252
+ self . all_objects . get ( & obj_ref. id ) . unwrap ( )
253
253
}
254
254
pub fn deref_mut ( & mut self , obj_ref : & ObjectRef ) -> & mut Object {
255
255
// TODO: check the reference is valid
256
- self . all_objects . get_mut ( obj_ref) . unwrap ( )
256
+ self . all_objects . get_mut ( & obj_ref. id ) . unwrap ( )
257
257
}
258
258
}
259
259
0 commit comments