Skip to content

Commit

Permalink
Prefer Option<&T> over &Option<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Aug 16, 2023
1 parent a43b9ae commit 6b1c82e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/display/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn print(
"{}",
style::header(
display_path,
extra_info,
extra_info.as_ref(),
i + 1,
hunks.len(),
file_format,
Expand Down
8 changes: 4 additions & 4 deletions src/display/side_by_side.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn format_missing_line_num(
/// Display `src` in a single column (e.g. a file removal or addition).
fn display_single_column(
display_path: &str,
old_path: &Option<String>,
old_path: Option<&String>,
file_format: &FileFormat,
src_lines: &[String],
side: Side,
Expand Down Expand Up @@ -320,7 +320,7 @@ pub fn print(
hunks: &[Hunk],
display_options: &DisplayOptions,
display_path: &str,
old_path: &Option<String>,
old_path: Option<&String>,
file_format: &FileFormat,
lhs_src: &str,
rhs_src: &str,
Expand Down Expand Up @@ -667,7 +667,7 @@ mod tests {
// Basic smoke test.
let res_lines = display_single_column(
"foo.py",
&None,
None,
&FileFormat::SupportedLanguage(Language::Python),
&["print(123)\n".to_string()],
Side::Right,
Expand Down Expand Up @@ -724,7 +724,7 @@ mod tests {
&hunks,
&DisplayOptions::default(),
"foo-new.el",
&None,
None,
&FileFormat::SupportedLanguage(Language::EmacsLisp),
"foo",
"bar",
Expand Down
2 changes: 1 addition & 1 deletion src/display/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub(crate) fn apply_line_number_color(

pub fn header(
display_path: &str,
extra_info: &Option<String>,
extra_info: Option<&String>,
hunk_num: usize,
hunk_total: usize,
file_format: &FileFormat,
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
"{}",
display::style::header(
&summary.display_path,
&summary.extra_info,
summary.extra_info.as_ref(),
1,
1,
&summary.file_format,
Expand All @@ -731,7 +731,7 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
"{}",
display::style::header(
&summary.display_path,
&summary.extra_info,
summary.extra_info.as_ref(),
1,
1,
&summary.file_format,
Expand Down Expand Up @@ -769,7 +769,7 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
hunks,
display_options,
&summary.display_path,
&summary.extra_info,
summary.extra_info.as_ref(),
&summary.file_format,
lhs_src,
rhs_src,
Expand All @@ -785,7 +785,7 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
"{}",
display::style::header(
&summary.display_path,
&summary.extra_info,
summary.extra_info.as_ref(),
1,
1,
&FileFormat::Binary,
Expand All @@ -806,7 +806,7 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
"{}",
display::style::header(
&summary.display_path,
&summary.extra_info,
summary.extra_info.as_ref(),
1,
1,
&FileFormat::Binary,
Expand Down

0 comments on commit 6b1c82e

Please sign in to comment.