Let..else refactor (#6562)

pull/6568/head
Casper Rogild Storm 1 year ago committed by GitHub
parent 1073dd6329
commit 9420ba7484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2125,20 +2125,16 @@ fn reset_diff_change(
let scrolloff = editor.config().scrolloff; let scrolloff = editor.config().scrolloff;
let (view, doc) = current!(editor); let (view, doc) = current!(editor);
// TODO refactor to use let..else once MSRV is raised to 1.65 let Some(handle) = doc.diff_handle() else {
let handle = match doc.diff_handle() { bail!("Diff is not available in the current buffer")
Some(handle) => handle,
None => bail!("Diff is not available in the current buffer"),
}; };
let diff = handle.load(); let diff = handle.load();
let doc_text = doc.text().slice(..); let doc_text = doc.text().slice(..);
let line = doc.selection(view.id).primary().cursor_line(doc_text); let line = doc.selection(view.id).primary().cursor_line(doc_text);
// TODO refactor to use let..else once MSRV is raised to 1.65 let Some(hunk_idx) = diff.hunk_at(line as u32, true) else {
let hunk_idx = match diff.hunk_at(line as u32, true) { bail!("There is no change at the cursor")
Some(hunk_idx) => hunk_idx,
None => bail!("There is no change at the cursor"),
}; };
let hunk = diff.nth_hunk(hunk_idx); let hunk = diff.nth_hunk(hunk_idx);
let diff_base = diff.diff_base(); let diff_base = diff.diff_base();

Loading…
Cancel
Save