Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a type to iterate over data as if it was with known type #481

Open
zhiburt opened this issue Jan 21, 2025 · 2 comments
Open

Create a type to iterate over data as if it was with known type #481

zhiburt opened this issue Jan 21, 2025 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zhiburt
Copy link
Owner

zhiburt commented Jan 21, 2025

It's often used approach to index some batch of columns/rows.

E.g.

for entry in 1 .. table.count_rows() / Swim::LENGTH { 
  style.insert_horizontal_line(entry * Swim::LENGTH, HorizontalLine::inherit(Style::modern())); 
 } 

All these math tricks are better be hidden,
So we could have something like.

table.count_records::<Swim>() -> usize

Not sure about the interface but it's very useful thing if we could make it beautiful.

@zhiburt zhiburt added enhancement New feature or request good first issue Good for newcomers labels Jan 21, 2025
@zhiburt
Copy link
Owner Author

zhiburt commented Jan 21, 2025

The kicker here is that we are losing type information after building table.
But sometimes it's useful to know Tabled::LENGTH
And maybe even type of construction Table::kv or Table::new depending on the found interface

@zhiburt
Copy link
Owner Author

zhiburt commented Jan 21, 2025

TableIterator::from_table::<Type>(&table)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant