Skip to content

Commit a95ca00

Browse files
authored
Merge pull request #125 from cakebaker/clippy_fix_warnings
clippy: fix warnings from `unnecessary_unwrap` lint
2 parents 3654b82 + b59d9be commit a95ca00

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

src/params.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,15 @@ fn match_context_diff_params(
279279
context_count = Some(numvalue.as_str().parse::<usize>().unwrap());
280280
}
281281
}
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}'")),
293291
}
294292
}
295293
}
@@ -325,17 +323,15 @@ fn match_unified_diff_params(
325323
context_count = Some(numvalue.as_str().parse::<usize>().unwrap());
326324
}
327325
}
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}'")),
339335
}
340336
}
341337
}

0 commit comments

Comments
 (0)