-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat: Add column_count, row_count and is_empty methods #119
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #119 +/- ##
==========================================
- Coverage 96.52% 96.36% -0.16%
==========================================
Files 19 18 -1
Lines 1754 1763 +9
==========================================
+ Hits 1693 1699 +6
- Misses 61 64 +3
|
Thanks for your contribution! I'm currently on holiday until next week and won't be able to review your PR until then :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually want to challenge the addition of the _count
methods.
I'm not sure if this is particularily useful, since the alternative .row_iter().count()
and .column_iter().count()
really isn't that much longer and more complex.
I don't see the benefit of adding this yet.
Regarding the is_empty()
call; I'm a bit more inclined to do this, since the alternative would be row_iter().next().is_none()
, which isn't ergonomic at all.
But I want to ponder for a moment on what an empty table actually is?
Is it a table without rows?
What if there's a header?
What if there're rows, but the rows don't have any cells?
Personally I'm not sure which of these conditions should be met for a table to be considered empty.
The current implementation avoids constructing an iterator which is then immediately consumed by the
Yes I was thinking about the same stuff you did. Currently I consider the table to be empty if there are no data rows. This excludes the header. A header being there without any data rows is still considered empty. We could expand this implementation and also check if the rows contain cells, and if they don't, the table will be empty. |
Any update on this? @Nukesor |
I guess these changes are fine :) The argument of "a table is empty if no data rows are in it" seems reasonable as well. Thanks for the contribution! |
This PR adds three methods:
column_count
: Returns the number of columns in the tablerow_count
: Returns the number of rows in the tableis_empty
: Returns if the table is empty (contains no data rows)