Skip to content

Commit 0777231

Browse files
committed
chore: clippy
1 parent d7d3bdf commit 0777231

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/components/table_content.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::await_holding_refcell_ref)]
2+
13
use crate::components::renderer_fn::renderer_fn;
24
use crate::loaded_rows::{LoadedRows, RowState};
35
use crate::selection::Selection;
@@ -230,6 +232,7 @@ where
230232
let set_known_row_count = set_known_row_count.clone();
231233

232234
async move {
235+
// TODO: can we avoid this?
233236
let row_count = rows.borrow().row_count().await;
234237

235238
// check if this component was disposed of
@@ -298,7 +301,7 @@ where
298301
});
299302

300303
let selected_indices = match selection {
301-
Selection::None => Signal::derive(|| HashSet::new()),
304+
Selection::None => Signal::stored(HashSet::new()),
302305
Selection::Single(selected_index) => Signal::derive(move || {
303306
selected_index
304307
.get()
@@ -479,6 +482,7 @@ where
479482
async move {
480483
let latest_reload_count = reload_count.get_untracked();
481484

485+
// TODO: can we avoid this?
482486
let result = rows
483487
.borrow()
484488
.get_rows(missing_range.clone())
@@ -520,7 +524,7 @@ where
520524
let on_selection_change = on_selection_change.clone();
521525

522526
view! {
523-
{row_placeholder_renderer.run(placeholder_height_before.into())}
527+
{row_placeholder_renderer.run(placeholder_height_before)}
524528

525529
<For
526530
each=move || {
@@ -576,7 +580,7 @@ where
576580

577581
let on_select = {
578582
let on_selection_change = on_selection_change.clone();
579-
let row = row.clone();
583+
580584
move |evt: web_sys::MouseEvent| {
581585
update_selection(evt, selection, first_selected_index, i);
582586

@@ -640,7 +644,7 @@ where
640644
}
641645
/>
642646

643-
{row_placeholder_renderer.run(placeholder_height_after.into())}
647+
{row_placeholder_renderer.run(placeholder_height_after)}
644648
}
645649
.into_any()
646650
};
@@ -683,10 +687,8 @@ fn compute_average_row_height_from_loaded<Row, ClsP>(
683687
loading_row_start_index = Some(i);
684688
}
685689
loading_row_end_index = Some(i);
686-
} else {
687-
if loading_row_end_index.is_some() {
688-
break;
689-
}
690+
} else if loading_row_end_index.is_some() {
691+
break;
690692
}
691693
}
692694

src/data_provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ where
143143

144144
/// Return `vec[range.start..range.end]` where `range` is clamped to the length of `vec`.
145145
pub fn get_vec_range_clamped<T: Clone>(
146-
vec: &Vec<T>,
146+
vec: &[T],
147147
range: Range<usize>,
148148
) -> (Vec<T>, Range<usize>) {
149149
if vec.is_empty() {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
//! You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
9999
//! - `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
100100
//! - `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
101+
//!
101102
//! See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
102103
//! [selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
103104
//! - **`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.

src/row_reader.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ use std::rc::Rc;
66
/// loading and caching automatically.
77
#[derive(Clone)]
88
pub struct RowReader<Row: Send + Sync + 'static> {
9-
pub(crate) get_loaded_rows: Rc<RefCell<Box<dyn Fn(usize) -> RowState<Row>>>>,
9+
pub(crate) get_loaded_rows: LoadedRowsGetter<Row>,
1010
}
1111

12+
pub type LoadedRowsGetter<Row> = Rc<RefCell<Box<dyn Fn(usize) -> RowState<Row>>>>;
13+
1214
impl<Row: Send + Sync + 'static> Default for RowReader<Row> {
1315
fn default() -> Self {
1416
Self {

0 commit comments

Comments
 (0)