remove redundant generic

This commit is contained in:
🪞👃🪞 2025-03-24 03:57:43 +02:00
parent 870bf249d8
commit d26c46d6e1
3 changed files with 6 additions and 8 deletions

View file

@ -12,7 +12,7 @@ pub struct Taggart {
pub cursor: usize, pub cursor: usize,
pub offset: usize, pub offset: usize,
pub column: usize, pub column: usize,
pub columns: Columns<Entry, fn(&Entry)->Option<Arc<str>>, fn(&mut [Entry], usize, &str)>, pub columns: Columns<fn(&Entry)->Option<Arc<str>>, fn(&mut [Entry], usize, &str)>,
pub display: Measure<TuiOut>, pub display: Measure<TuiOut>,
pub tasks: Vec<Task>, pub tasks: Vec<Task>,
pub mode: Option<Mode>, pub mode: Option<Mode>,

View file

@ -1,9 +1,8 @@
use crate::*; use crate::*;
pub struct Columns<T, G, S>(pub Vec<Column<T, G, S>>); pub struct Columns<G, S>(pub Vec<Column<G, S>>);
pub struct Column<T, G, S> { pub struct Column<G, S> {
__: std::marker::PhantomData<T>,
pub title: Arc<str>, pub title: Arc<str>,
pub width: usize, pub width: usize,
pub getter: G, pub getter: G,
@ -11,7 +10,7 @@ pub struct Column<T, G, S> {
//pub styler: Option<U>, //pub styler: Option<U>,
} }
impl<T> Column<T, fn(&T)->Option<Arc<str>>, fn(&mut [T], usize, &str)> { impl<T> Column<fn(&T)->Option<Arc<str>>, fn(&mut [T], usize, &str)> {
pub fn new ( pub fn new (
title: &impl AsRef<str>, title: &impl AsRef<str>,
width: usize, width: usize,
@ -22,7 +21,6 @@ impl<T> Column<T, fn(&T)->Option<Arc<str>>, fn(&mut [T], usize, &str)> {
title: title.as_ref().into(), title: title.as_ref().into(),
getter, getter,
setter: None, setter: None,
__: Default::default(),
} }
} }
fn setter (mut self, setter: fn(&mut [T], usize, &str)) -> Self { fn setter (mut self, setter: fn(&mut [T], usize, &str)) -> Self {
@ -45,7 +43,7 @@ macro_rules! setter {
} }
} }
impl Default for Columns<Entry, fn(&Entry)->Option<Arc<str>>, fn(&mut [Entry], usize, &str)> { impl Default for Columns<fn(&Entry)->Option<Arc<str>>, fn(&mut [Entry], usize, &str)> {
fn default () -> Self { fn default () -> Self {
Self(vec![ Self(vec![
Column::new(&"Hash", 8, |entry: &Entry|entry.hash()), Column::new(&"Hash", 8, |entry: &Entry|entry.hash()),

View file

@ -83,7 +83,7 @@ impl<'a> TreeTable<'a> {
} }
} }
impl<T, G, S> Columns<T, G, S> { impl<G, S> Columns<G, S> {
pub fn header (&self) -> Arc<str> { pub fn header (&self) -> Arc<str> {
let mut output = String::new(); let mut output = String::new();
for Column { width, title, .. } in self.0.iter() { for Column { width, title, .. } in self.0.iter() {