3333//! }
3434//! ```
3535
36- use crate :: vec:: { OwnedVecStorage , VecStorage , VecStorageInner , ViewVecStorage } ;
37- use crate :: CapacityError ;
38- use core:: cmp:: Ordering ;
39- use core:: fmt;
40- use core:: iter:: FusedIterator ;
41- use core:: marker:: PhantomData ;
42- use core:: mem:: { ManuallyDrop , MaybeUninit } ;
43- use core:: { ptr, slice} ;
36+ use crate :: {
37+ vec:: { OwnedVecStorage , VecStorage , VecStorageInner , ViewVecStorage } ,
38+ CapacityError ,
39+ } ;
40+ use core:: {
41+ cmp:: Ordering ,
42+ fmt,
43+ iter:: FusedIterator ,
44+ marker:: PhantomData ,
45+ mem:: { ManuallyDrop , MaybeUninit } ,
46+ ptr, slice,
47+ } ;
4448
4549#[ cfg( feature = "zeroize" ) ]
4650use zeroize:: Zeroize ;
@@ -173,14 +177,16 @@ impl<T, const N: usize> Deque<T, N> {
173177
174178 /// Returns the maximum number of elements the deque can hold.
175179 ///
176- /// This method is not available on a `DequeView`, use [`storage_capacity`](DequeInner::storage_capacity) instead.
180+ /// This method is not available on a `DequeView`, use
181+ /// [`storage_capacity`](DequeInner::storage_capacity) instead.
177182 pub const fn capacity ( & self ) -> usize {
178183 N
179184 }
180185
181186 /// Returns the number of elements currently in the deque.
182187 ///
183- /// This method is not available on a `DequeView`, use [`storage_len`](DequeInner::storage_len) instead.
188+ /// This method is not available on a `DequeView`, use [`storage_len`](DequeInner::storage_len)
189+ /// instead.
184190 pub const fn len ( & self ) -> usize {
185191 if self . full {
186192 N
@@ -452,8 +458,8 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
452458 self . storage_capacity ( ) - free,
453459 ) ;
454460
455- // because the deque wasn't contiguous, we know that `tail_len < self.len == slice.len()`,
456- // so this will never panic.
461+ // because the deque wasn't contiguous, we know that `tail_len < self.len ==
462+ // slice.len()`, so this will never panic.
457463 slice. rotate_left ( back_len) ;
458464
459465 // the used part of the buffer now is `free..self.capacity()`, so set
@@ -465,7 +471,8 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
465471 // head is shorter so:
466472 // 1. copy head backwards
467473 // 2. rotate used part of the buffer
468- // 3. update head to point to the new beginning (which is the beginning of the buffer)
474+ // 3. update head to point to the new beginning (which is the beginning of the
475+ // buffer)
469476
470477 unsafe {
471478 // if there is no free space in the buffer, then the slices are already
@@ -483,8 +490,8 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
483490 // next to each other, all the elements in the range are initialized.
484491 let slice: & mut [ T ] = slice:: from_raw_parts_mut ( buffer_ptr, len) ;
485492
486- // because the deque wasn't contiguous, we know that `head_len < self.len == slice.len()`
487- // so this will never panic.
493+ // because the deque wasn't contiguous, we know that `head_len < self.len ==
494+ // slice.len()` so this will never panic.
488495 slice. rotate_right ( front_len) ;
489496
490497 // the used part of the buffer now is `0..self.len`, so set
@@ -844,11 +851,11 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
844851 }
845852
846853 // Safety:
847- // * Any slice passed to `drop_in_place` is valid; the second case has
848- // `len <= front.len()` and returning on `len > self.storage_len()` ensures
849- // `begin <= back.len()` in the first case
850- // * Deque front/back cursors are moved before calling `drop_in_place`,
851- // so no value is dropped twice if `drop_in_place` panics
854+ // * Any slice passed to `drop_in_place` is valid; the second case has `len <= front.len()`
855+ // and returning on `len > self.storage_len()` ensures `begin <= back.len()` in the first
856+ // case
857+ // * Deque front/back cursors are moved before calling `drop_in_place`, so no value is
858+ // dropped twice if `drop_in_place` panics
852859 unsafe {
853860 // If new desired length is greater or equal, we don't need to act.
854861 if len >= self . storage_len ( ) {
@@ -865,8 +872,9 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
865872 let drop_back = back. get_unchecked_mut ( begin..) as * mut _ ;
866873
867874 // Self::to_physical_index returns the index `len` units _after_ the front cursor,
868- // meaning we can use it to find the decremented index for `back` for non-contiguous deques,
869- // as well as determine where the new "cap" for front needs to be placed for contiguous deques.
875+ // meaning we can use it to find the decremented index for `back` for non-contiguous
876+ // deques, as well as determine where the new "cap" for front needs
877+ // to be placed for contiguous deques.
870878 self . back = self . to_physical_index ( len) ;
871879 self . full = false ;
872880
@@ -880,8 +888,9 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
880888 self . back = self . to_physical_index ( len) ;
881889 self . full = false ;
882890
883- // If `drop_front` causes a panic, the Dropper will still be called to drop it's slice during unwinding.
884- // In either case, front will always be dropped before back.
891+ // If `drop_front` causes a panic, the Dropper will still be called to drop it's
892+ // slice during unwinding. In either case, front will always be
893+ // dropped before back.
885894 let _back_dropper = Dropper ( & mut * drop_back) ;
886895 ptr:: drop_in_place ( drop_front) ;
887896 }
@@ -970,7 +979,8 @@ impl<T, S: VecStorage<T> + ?Sized> DequeInner<T, S> {
970979 cur += 1 ;
971980 idx += 1 ;
972981 }
973- // Stage 2: Swap retained values into current idx, building a contiguous chunk from 0 to idx.
982+ // Stage 2: Swap retained values into current idx, building a contiguous chunk from 0 to
983+ // idx.
974984 while cur < len {
975985 let val = self
976986 . get_mut ( cur)
0 commit comments