@@ -279,17 +279,15 @@ fn match_context_diff_params(
279
279
context_count = Some ( numvalue. as_str ( ) . parse :: < usize > ( ) . unwrap ( ) ) ;
280
280
}
281
281
}
282
- if param == "-C" && next_param. is_some ( ) {
283
- match next_param. unwrap ( ) . to_string_lossy ( ) . parse :: < usize > ( ) {
284
- Ok ( context_size) => {
285
- context_count = Some ( context_size) ;
286
- next_param_consumed = true ;
287
- }
288
- Err ( _) => {
289
- return Err ( format ! (
290
- "invalid context length '{}'" ,
291
- next_param. unwrap( ) . to_string_lossy( )
292
- ) )
282
+ if param == "-C" {
283
+ if let Some ( p) = next_param {
284
+ let size_str = p. to_string_lossy ( ) ;
285
+ match size_str. parse :: < usize > ( ) {
286
+ Ok ( context_size) => {
287
+ context_count = Some ( context_size) ;
288
+ next_param_consumed = true ;
289
+ }
290
+ Err ( _) => return Err ( format ! ( "invalid context length '{size_str}'" ) ) ,
293
291
}
294
292
}
295
293
}
@@ -325,17 +323,15 @@ fn match_unified_diff_params(
325
323
context_count = Some ( numvalue. as_str ( ) . parse :: < usize > ( ) . unwrap ( ) ) ;
326
324
}
327
325
}
328
- if param == "-U" && next_param. is_some ( ) {
329
- match next_param. unwrap ( ) . to_string_lossy ( ) . parse :: < usize > ( ) {
330
- Ok ( context_size) => {
331
- context_count = Some ( context_size) ;
332
- next_param_consumed = true ;
333
- }
334
- Err ( _) => {
335
- return Err ( format ! (
336
- "invalid context length '{}'" ,
337
- next_param. unwrap( ) . to_string_lossy( )
338
- ) )
326
+ if param == "-U" {
327
+ if let Some ( p) = next_param {
328
+ let size_str = p. to_string_lossy ( ) ;
329
+ match size_str. parse :: < usize > ( ) {
330
+ Ok ( context_size) => {
331
+ context_count = Some ( context_size) ;
332
+ next_param_consumed = true ;
333
+ }
334
+ Err ( _) => return Err ( format ! ( "invalid context length '{size_str}'" ) ) ,
339
335
}
340
336
}
341
337
}
0 commit comments