From 5e151cdc42319e28bd7ac6a9a9c3cecc4e6d129b Mon Sep 17 00:00:00 2001 From: RumovZ Date: Wed, 31 Mar 2021 00:02:10 +0200 Subject: [PATCH] Pass Column by value --- rslib/src/browser_table.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rslib/src/browser_table.rs b/rslib/src/browser_table.rs index ba0150772..bbfb31b6d 100644 --- a/rslib/src/browser_table.rs +++ b/rslib/src/browser_table.rs @@ -79,13 +79,13 @@ pub struct Font { } trait RowContext { - fn get_cell_text(&mut self, column: &Column) -> Result; + fn get_cell_text(&mut self, column: Column) -> Result; fn get_row_color(&self) -> Color; fn get_row_font(&self) -> Result; fn note(&self) -> &Note; fn notetype(&self) -> &Notetype; - fn get_cell(&mut self, column: &Column) -> Result { + fn get_cell(&mut self, column: Column) -> Result { Ok(Cell { text: self.get_cell_text(column)?, is_rtl: self.get_is_rtl(column), @@ -103,7 +103,7 @@ trait RowContext { html_to_text_line(&self.note().fields()[index]).into() } - fn get_is_rtl(&self, column: &Column) -> bool { + fn get_is_rtl(&self, column: Column) -> bool { match column { Column::NoteField => { let index = self.notetype().config.sort_field_idx as usize; @@ -117,7 +117,7 @@ trait RowContext { Ok(Row { cells: columns .iter() - .map(|column| self.get_cell(column)) + .map(|&column| self.get_cell(column)) .collect::>()?, color: self.get_row_color(), font: self.get_row_font()?, @@ -389,7 +389,7 @@ impl<'a> CardRowContext<'a> { } impl RowContext for CardRowContext<'_> { - fn get_cell_text(&mut self, column: &Column) -> Result { + fn get_cell_text(&mut self, column: Column) -> Result { Ok(match column { Column::Question => self.question_str(), Column::Answer => self.answer_str(), @@ -516,7 +516,7 @@ impl<'a> NoteRowContext<'a> { } impl RowContext for NoteRowContext<'_> { - fn get_cell_text(&mut self, column: &Column) -> Result { + fn get_cell_text(&mut self, column: Column) -> Result { Ok(match column { Column::NoteCards => self.cards.len().to_string(), Column::NoteCreation => self.note_creation_str(),