@@ -80,7 +80,7 @@ struct RawBucket<K, V, M> {
80
80
impl < K , V , M > Copy for RawBucket < K , V , M > { }
81
81
82
82
#[ derive( Clone ) ]
83
- pub struct TableRef < M > ( M ) ;
83
+ pub struct TableRef < M > ( pub M ) ;
84
84
85
85
impl < M : Copy > Copy for TableRef < M > { }
86
86
@@ -162,7 +162,7 @@ impl<K, V, M> Deref for TableRef<M> where RawTable<K, V>: BorrowFrom<M> {
162
162
type Target = RawTable < K , V > ;
163
163
164
164
fn deref ( & self ) -> & RawTable < K , V > {
165
- BorrowFrom :: borrow_from ( & mut self . 0 )
165
+ BorrowFrom :: borrow_from ( & self . 0 )
166
166
}
167
167
}
168
168
@@ -255,17 +255,18 @@ impl<K, V, M> Bucket<K, V, M> where RawTable<K, V>: BorrowFrom<M> {
255
255
-> Result < Bucket < K , V , M > , Bucket < K , V , M , bucket:: TableIsEmpty > >
256
256
{
257
257
let table = TableRef ( table) ;
258
+ let capacity = table. capacity ( ) ;
258
259
let ib_index = ib_index & ( table. capacity ( ) - 1 ) ;
259
260
let bb = BareBucket {
260
261
raw : unsafe {
261
262
table. first_bucket_raw ( ) . offset ( ib_index as int )
262
263
} ,
263
264
idx : ib_index,
264
- capacity : table . capacity ( ) ,
265
+ capacity : capacity,
265
266
table : table,
266
267
} ;
267
268
268
- if table . capacity ( ) == 0 {
269
+ if capacity == 0 {
269
270
Err ( Bucket ( bb) )
270
271
} else {
271
272
Ok ( Bucket ( bb) )
@@ -278,7 +279,7 @@ impl<K, V, M> Bucket<K, V, M> where RawTable<K, V>: BorrowFrom<M> {
278
279
279
280
/// Narrows down the range of iteration, which must be a power of 2.
280
281
pub fn iter_to ( mut self , limit : usize ) -> Bucket < K , V , M > {
281
- assert ! ( limit <= TableRef ( & self . table) . capacity( ) ) ;
282
+ assert ! ( limit <= self . 0 . table. capacity( ) ) ;
282
283
assert ! ( limit. is_power_of_two( ) ) ;
283
284
self . 0 . capacity = limit;
284
285
self
@@ -770,7 +771,7 @@ impl<K, V> Drop for RawTable<K, V> {
770
771
// Avoid double drop of elements that have been already moved out.
771
772
unsafe {
772
773
if self . size != 0 {
773
- for bucket in Bucket :: raw_full_buckets ( self ) {
774
+ for bucket in Bucket :: raw_full_buckets ( & mut * self ) {
774
775
ptr:: read ( bucket. kval ) ;
775
776
}
776
777
}
0 commit comments