@@ -35,57 +35,58 @@ impl TabHandles {
3535 self . handles . clear ( ) ;
3636 }
3737
38- pub ( crate ) fn with_group < ' a > (
39- & ' a self ,
40- focused_id : Option < & FocusId > ,
41- ) -> Box < dyn Iterator < Item = & ' a FocusHandle > + ' a > {
38+ pub ( crate ) fn with_group < ' a > ( & ' a self , focused_id : Option < & FocusId > ) -> Vec < FocusHandle > {
4239 if let Some ( focused_id) = focused_id {
4340 if let Some ( handle) = self . handles . iter ( ) . find ( |h| & h. id == focused_id) {
44- return Box :: new (
45- self . handles
46- . iter ( )
47- . filter ( |h| h. tab_group == handle. tab_group ) ,
48- ) ;
41+ return self
42+ . handles
43+ . iter ( )
44+ . cloned ( )
45+ . filter ( |h| h. tab_group == handle. tab_group )
46+ . collect ( ) ;
4947 }
5048 }
5149
52- Box :: new ( self . handles . iter ( ) . filter ( |h| h. tab_group . is_none ( ) ) )
50+ self . handles
51+ . iter ( )
52+ . cloned ( )
53+ . filter ( |h| h. tab_group . is_none ( ) )
54+ . collect ( )
5355 }
5456
5557 pub ( crate ) fn next ( & self , focused_id : Option < & FocusId > ) -> Option < FocusHandle > {
56- let group_handles: Vec < & FocusHandle > = self . with_group ( focused_id) . collect ( ) ;
58+ let group_handles = self . with_group ( focused_id) ;
5759 let ix = group_handles
5860 . iter ( )
5961 . position ( |h| Some ( & h. id ) == focused_id)
6062 . unwrap_or_default ( ) ;
6163
6264 let mut next_ix = ix + 1 ;
63- if next_ix + 1 > group_handles. len ( ) {
65+ if next_ix >= group_handles. len ( ) {
6466 next_ix = 0 ;
6567 }
6668
67- if let Some ( next_handle) = group_handles. get ( next_ix) . cloned ( ) {
69+ if let Some ( next_handle) = group_handles. get ( next_ix) {
6870 Some ( next_handle. clone ( ) )
6971 } else {
7072 None
7173 }
7274 }
7375
7476 pub ( crate ) fn prev ( & self , focused_id : Option < & FocusId > ) -> Option < FocusHandle > {
75- let group_handles: Vec < & FocusHandle > = self . with_group ( focused_id) . collect ( ) ;
77+ let group_handles = self . with_group ( focused_id) ;
7678 let ix = group_handles
7779 . iter ( )
7880 . position ( |h| Some ( & h. id ) == focused_id)
7981 . unwrap_or_default ( ) ;
8082
81- let prev_ix;
82- if ix == 0 {
83- prev_ix = group_handles. len ( ) . saturating_sub ( 1 ) ;
83+ let prev_ix = if ix == 0 {
84+ group_handles. len ( ) . saturating_sub ( 1 )
8485 } else {
85- prev_ix = ix. saturating_sub ( 1 ) ;
86- }
86+ ix. saturating_sub ( 1 )
87+ } ;
8788
88- if let Some ( prev_handle) = group_handles. get ( prev_ix) . cloned ( ) {
89+ if let Some ( prev_handle) = group_handles. get ( prev_ix) {
8990 Some ( prev_handle. clone ( ) )
9091 } else {
9192 None
0 commit comments