@@ -80,7 +80,7 @@ struct RawBucket<K, V, M> {
8080impl < K , V , M > Copy for RawBucket < K , V , M > { }
8181
8282#[ derive( Clone ) ]
83- pub struct TableRef < M > ( M ) ;
83+ pub struct TableRef < M > ( pub M ) ;
8484
8585impl < M : Copy > Copy for TableRef < M > { }
8686
@@ -162,7 +162,7 @@ impl<K, V, M> Deref for TableRef<M> where RawTable<K, V>: BorrowFrom<M> {
162162 type Target = RawTable < K , V > ;
163163
164164 fn deref ( & self ) -> & RawTable < K , V > {
165- BorrowFrom :: borrow_from ( & mut self . 0 )
165+ BorrowFrom :: borrow_from ( & self . 0 )
166166 }
167167}
168168
@@ -255,17 +255,18 @@ impl<K, V, M> Bucket<K, V, M> where RawTable<K, V>: BorrowFrom<M> {
255255 -> Result < Bucket < K , V , M > , Bucket < K , V , M , bucket:: TableIsEmpty > >
256256 {
257257 let table = TableRef ( table) ;
258+ let capacity = table. capacity ( ) ;
258259 let ib_index = ib_index & ( table. capacity ( ) - 1 ) ;
259260 let bb = BareBucket {
260261 raw : unsafe {
261262 table. first_bucket_raw ( ) . offset ( ib_index as int )
262263 } ,
263264 idx : ib_index,
264- capacity : table . capacity ( ) ,
265+ capacity : capacity,
265266 table : table,
266267 } ;
267268
268- if table . capacity ( ) == 0 {
269+ if capacity == 0 {
269270 Err ( Bucket ( bb) )
270271 } else {
271272 Ok ( Bucket ( bb) )
@@ -278,7 +279,7 @@ impl<K, V, M> Bucket<K, V, M> where RawTable<K, V>: BorrowFrom<M> {
278279
279280 /// Narrows down the range of iteration, which must be a power of 2.
280281 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( ) ) ;
282283 assert ! ( limit. is_power_of_two( ) ) ;
283284 self . 0 . capacity = limit;
284285 self
@@ -770,7 +771,7 @@ impl<K, V> Drop for RawTable<K, V> {
770771 // Avoid double drop of elements that have been already moved out.
771772 unsafe {
772773 if self . size != 0 {
773- for bucket in Bucket :: raw_full_buckets ( self ) {
774+ for bucket in Bucket :: raw_full_buckets ( & mut * self ) {
774775 ptr:: read ( bucket. kval ) ;
775776 }
776777 }
0 commit comments