-
Notifications
You must be signed in to change notification settings - Fork 164
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
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
edf9165
Refactor table metadata retrieval for reuse
wdoppenberg 6f10fce
Tests; owned data method; duplication removed
wdoppenberg a536d36
Refactor test to use `table_by_name_ref` and `DataRef` assertions.
wdoppenberg 854d025
formatting
wdoppenberg 7f6ef63
Swapped `into_data` for `From` implementation
wdoppenberg e9d6dee
Removed trait bounds to satisfy MR feedback; Fixed test
wdoppenberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,7 +468,7 @@ impl<T: CellType> Range<T> { | |
// search bounds | ||
let row_start = cells.first().unwrap().pos.0; | ||
let row_end = cells.last().unwrap().pos.0; | ||
let mut col_start = std::u32::MAX; | ||
let mut col_start = u32::MAX; | ||
let mut col_end = 0; | ||
for c in cells.iter().map(|c| c.pos.1) { | ||
if c < col_start { | ||
|
@@ -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> { | ||
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> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, it is unnecessary I think. |
||
/// Get the name of the table | ||
pub fn name(&self) -> &str { | ||
&self.name | ||
|
@@ -957,6 +957,12 @@ impl<T> Table<T> { | |
} | ||
} | ||
|
||
impl<T: CellType> From<Table<T>> for Range<T> { | ||
fn from(table: Table<T>) -> Range<T> { | ||
table.data | ||
} | ||
} | ||
|
||
/// A helper function to deserialize cell values as `i64`, | ||
/// useful when cells may also contain invalid values (i.e. strings). | ||
/// It applies the [`as_i64`] method to the cell value, and returns | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think it is better to refrain from adding constraints on the structs, the impl are enough, more generic and more future proof.