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

feat: named table data as DataRef type #464

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

wdoppenberg
Copy link
Contributor

@wdoppenberg wdoppenberg commented Sep 3, 2024

During some work I was performing on a MR for fastexcel (ToucanToco/fastexcel#282) I noticed no method for retrieving Tables with DataRef as inner type was not possible. This MR should hopefully resolve this issue.

I also implemented From<Table<T>> for Range<T> to prevent large clone operations, which I ran into in one method in particular inside fastexcel.

Finally I resolved a small clippy warning mentioning that std::u32::MAX is deprecated.

Eager to receive your feedback :)

Extracted table metadata retrieval into a separate function `get_table_meta` for code reuse and clarity. This change simplifies the `table_by_name` function and introduces a new `table_by_name_ref` function that also leverages the shared `get_table_meta` functionality.
Copy link
Owner

@tafia tafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Small comments to keep it as generic as possible.

src/lib.rs Outdated
@@ -932,13 +932,13 @@ impl<'a, T: 'a + CellType> DoubleEndedIterator for Rows<'a, T> {
impl<'a, T: 'a + CellType> ExactSizeIterator for Rows<'a, T> {}

/// Struct with the key elements of a table
pub struct Table<T> {
pub struct Table<T: CellType> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to refrain from adding constraints on the structs, the impl are enough, more generic and more future proof.

src/lib.rs Outdated
pub(crate) name: String,
pub(crate) sheet_name: String,
pub(crate) columns: Vec<String>,
pub(crate) data: Range<T>,
}
impl<T> Table<T> {
impl<T: CellType> Table<T> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, it is unnecessary I think.

@wdoppenberg wdoppenberg requested a review from tafia September 16, 2024 06:59
@wdoppenberg
Copy link
Contributor Author

@tafia Is there anything else you need me to change in this PR?

@tafia
Copy link
Owner

tafia commented Oct 3, 2024

Sorry for the late answer lgtm!

@tafia tafia merged commit 06a1093 into tafia:master Oct 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants