@@ -98,7 +98,7 @@ impl<T> VecDeque<T> {
98
98
// For zero sized types, we are always at maximum capacity
99
99
MAXIMUM_ZST_CAPACITY
100
100
} else {
101
- self . buf . cap ( )
101
+ self . buf . capacity ( )
102
102
}
103
103
}
104
104
@@ -314,10 +314,10 @@ impl<T> VecDeque<T> {
314
314
}
315
315
316
316
/// Frobs the head and tail sections around to handle the fact that we
317
- /// just reallocated. Unsafe because it trusts old_cap .
317
+ /// just reallocated. Unsafe because it trusts old_capacity .
318
318
#[ inline]
319
- unsafe fn handle_cap_increase ( & mut self , old_cap : usize ) {
320
- let new_cap = self . cap ( ) ;
319
+ unsafe fn handle_capacity_increase ( & mut self , old_capacity : usize ) {
320
+ let new_capacity = self . cap ( ) ;
321
321
322
322
// Move the shortest contiguous section of the ring buffer
323
323
// T H
@@ -336,15 +336,15 @@ impl<T> VecDeque<T> {
336
336
if self . tail <= self . head {
337
337
// A
338
338
// Nop
339
- } else if self . head < old_cap - self . tail {
339
+ } else if self . head < old_capacity - self . tail {
340
340
// B
341
- self . copy_nonoverlapping ( old_cap , 0 , self . head ) ;
342
- self . head += old_cap ;
341
+ self . copy_nonoverlapping ( old_capacity , 0 , self . head ) ;
342
+ self . head += old_capacity ;
343
343
debug_assert ! ( self . head > self . tail) ;
344
344
} else {
345
345
// C
346
- let new_tail = new_cap - ( old_cap - self . tail ) ;
347
- self . copy_nonoverlapping ( new_tail, self . tail , old_cap - self . tail ) ;
346
+ let new_tail = new_capacity - ( old_capacity - self . tail ) ;
347
+ self . copy_nonoverlapping ( new_tail, self . tail , old_capacity - self . tail ) ;
348
348
self . tail = new_tail;
349
349
debug_assert ! ( self . head < self . tail) ;
350
350
}
@@ -551,7 +551,7 @@ impl<T> VecDeque<T> {
551
551
if new_cap > old_cap {
552
552
self . buf . reserve_exact ( used_cap, new_cap - used_cap) ;
553
553
unsafe {
554
- self . handle_cap_increase ( old_cap) ;
554
+ self . handle_capacity_increase ( old_cap) ;
555
555
}
556
556
}
557
557
}
@@ -641,7 +641,7 @@ impl<T> VecDeque<T> {
641
641
if new_cap > old_cap {
642
642
self . buf . try_reserve_exact ( used_cap, new_cap - used_cap) ?;
643
643
unsafe {
644
- self . handle_cap_increase ( old_cap) ;
644
+ self . handle_capacity_increase ( old_cap) ;
645
645
}
646
646
}
647
647
Ok ( ( ) )
@@ -1887,7 +1887,7 @@ impl<T> VecDeque<T> {
1887
1887
let old_cap = self . cap ( ) ;
1888
1888
self . buf . double ( ) ;
1889
1889
unsafe {
1890
- self . handle_cap_increase ( old_cap) ;
1890
+ self . handle_capacity_increase ( old_cap) ;
1891
1891
}
1892
1892
debug_assert ! ( !self . is_full( ) ) ;
1893
1893
}
@@ -2736,9 +2736,9 @@ impl<T> From<Vec<T>> for VecDeque<T> {
2736
2736
2737
2737
// We need to extend the buf if it's not a power of two, too small
2738
2738
// or doesn't have at least one free space
2739
- if !buf. cap ( ) . is_power_of_two ( ) || ( buf. cap ( ) < ( MINIMUM_CAPACITY + 1 ) ) ||
2740
- ( buf. cap ( ) == len) {
2741
- let cap = cmp:: max ( buf. cap ( ) + 1 , MINIMUM_CAPACITY + 1 ) . next_power_of_two ( ) ;
2739
+ if !buf. capacity ( ) . is_power_of_two ( ) || ( buf. capacity ( ) < ( MINIMUM_CAPACITY + 1 ) ) ||
2740
+ ( buf. capacity ( ) == len) {
2741
+ let cap = cmp:: max ( buf. capacity ( ) + 1 , MINIMUM_CAPACITY + 1 ) . next_power_of_two ( ) ;
2742
2742
buf. reserve_exact ( len, cap - len) ;
2743
2743
}
2744
2744
@@ -3153,8 +3153,8 @@ mod tests {
3153
3153
fn test_vec_from_vecdeque ( ) {
3154
3154
use crate :: vec:: Vec ;
3155
3155
3156
- fn create_vec_and_test_convert ( cap : usize , offset : usize , len : usize ) {
3157
- let mut vd = VecDeque :: with_capacity ( cap ) ;
3156
+ fn create_vec_and_test_convert ( capacity : usize , offset : usize , len : usize ) {
3157
+ let mut vd = VecDeque :: with_capacity ( capacity ) ;
3158
3158
for _ in 0 ..offset {
3159
3159
vd. push_back ( 0 ) ;
3160
3160
vd. pop_front ( ) ;
0 commit comments