File tree Expand file tree Collapse file tree 6 files changed +46
-48
lines changed Expand file tree Collapse file tree 6 files changed +46
-48
lines changed Original file line number Diff line number Diff line change @@ -776,19 +776,21 @@ impl App {
776
776
}
777
777
Action :: DeleteBranch ( branch_ref, false ) => {
778
778
self . queue . push (
779
- if let Some ( name) = branch_ref. rsplit ( '/' ) . next ( )
780
- {
781
- InternalEvent :: Push (
782
- name. to_string ( ) ,
783
- false ,
784
- true ,
785
- )
786
- } else {
787
- InternalEvent :: ShowErrorMsg ( format ! (
788
- "Failed to find the branch name in {}" ,
789
- branch_ref
790
- ) )
791
- } ,
779
+ branch_ref. rsplit ( '/' ) . next ( ) . map_or_else (
780
+ || {
781
+ InternalEvent :: ShowErrorMsg ( format ! (
782
+ "Failed to find the branch name in {}" ,
783
+ branch_ref
784
+ ) )
785
+ } ,
786
+ |name| {
787
+ InternalEvent :: Push (
788
+ name. to_string ( ) ,
789
+ false ,
790
+ true ,
791
+ )
792
+ } ,
793
+ ) ,
792
794
) ;
793
795
flags. insert ( NeedsUpdate :: ALL ) ;
794
796
self . select_branch_popup . update_branches ( ) ?;
Original file line number Diff line number Diff line change @@ -354,23 +354,23 @@ impl BlameFileComponent {
354
354
355
355
///
356
356
fn get_rows ( & self , width : usize ) -> Vec < Row > {
357
- if let Some ( ref file_blame ) = self . file_blame {
358
- file_blame
359
- . lines
360
- . iter ( )
361
- . enumerate ( )
362
- . map ( | ( i , ( blame_hunk , line ) ) | {
363
- self . get_line_blame (
364
- width ,
365
- i ,
366
- ( blame_hunk . as_ref ( ) , line . as_ref ( ) ) ,
367
- file_blame ,
368
- )
369
- } )
370
- . collect ( )
371
- } else {
372
- vec ! [ ]
373
- }
357
+ self . file_blame
358
+ . as_ref ( )
359
+ . map_or_else ( Vec :: new , |file_blame| {
360
+ file_blame
361
+ . lines
362
+ . iter ( )
363
+ . enumerate ( )
364
+ . map ( | ( i , ( blame_hunk , line ) ) | {
365
+ self . get_line_blame (
366
+ width ,
367
+ i ,
368
+ ( blame_hunk . as_ref ( ) , line . as_ref ( ) ) ,
369
+ file_blame ,
370
+ )
371
+ } )
372
+ . collect ( )
373
+ } )
374
374
}
375
375
376
376
fn get_line_blame (
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ impl DetailsComponent {
151
151
152
152
#[ allow( unstable_name_collisions, clippy:: too_many_lines) ]
153
153
fn get_text_info ( & self ) -> Vec < Spans > {
154
- if let Some ( ref data) = self . data {
154
+ self . data . as_ref ( ) . map_or_else ( Vec :: new , | data| {
155
155
let mut res = vec ! [
156
156
Spans :: from( vec![
157
157
style_detail( & self . theme, & Detail :: Author ) ,
@@ -235,9 +235,7 @@ impl DetailsComponent {
235
235
}
236
236
237
237
res
238
- } else {
239
- vec ! [ ]
240
- }
238
+ } )
241
239
}
242
240
243
241
fn move_scroll_top ( & mut self , move_type : ScrollType ) -> bool {
Original file line number Diff line number Diff line change @@ -286,11 +286,10 @@ impl CommitList {
286
286
287
287
// commit tags
288
288
txt. push ( Span :: styled (
289
- Cow :: from ( if let Some ( tags) = tags {
290
- format ! ( " {}" , tags)
291
- } else {
292
- String :: from ( "" )
293
- } ) ,
289
+ Cow :: from ( tags. map_or_else (
290
+ || String :: from ( "" ) ,
291
+ |tags| format ! ( " {}" , tags) ,
292
+ ) ) ,
294
293
theme. tags ( selected) ,
295
294
) ) ;
296
295
Original file line number Diff line number Diff line change @@ -368,11 +368,9 @@ impl TagListComponent {
368
368
369
369
///
370
370
fn get_rows ( & self ) -> Vec < Row > {
371
- if let Some ( ref tags) = self . tags {
371
+ self . tags . as_ref ( ) . map_or_else ( Vec :: new , | tags| {
372
372
tags. iter ( ) . map ( |tag| self . get_row ( tag) ) . collect ( )
373
- } else {
374
- vec ! [ ]
375
- }
373
+ } )
376
374
}
377
375
378
376
///
Original file line number Diff line number Diff line change @@ -181,15 +181,16 @@ impl Status {
181
181
chunks : & [ tui:: layout:: Rect ] ,
182
182
) {
183
183
if let Some ( branch_name) = self . git_branch_name . last ( ) {
184
- let ahead_behind =
185
- if let Some ( state) = & self . git_branch_state {
184
+ let ahead_behind = self
185
+ . git_branch_state
186
+ . as_ref ( )
187
+ . map_or_else ( String :: new, |state| {
186
188
format ! (
187
189
"\u{2191} {} \u{2193} {} " ,
188
190
state. ahead, state. behind,
189
191
)
190
- } else {
191
- String :: new ( )
192
- } ;
192
+ } ) ;
193
+
193
194
let w = Paragraph :: new ( format ! (
194
195
"{}{{{}}}" ,
195
196
ahead_behind, branch_name
You can’t perform that action at this time.
0 commit comments