Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
partialeq for rows/row view comparison
  • Loading branch information
molpopgen committed Nov 8, 2022
commit e6bf32ec8604aa7905c5413754d2572f50df4e52
25 changes: 23 additions & 2 deletions src/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ impl<'a> ProvenanceTableRowView<'a> {
}
}

impl<'a> PartialEq for ProvenanceTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id && self.timestamp == other.timestamp && self.record == other.record
}
}

impl Eq for ProvenanceTableRowView<'_> {}

impl<'a> PartialEq<ProvenanceTableRow> for ProvenanceTableRowView<'a> {
fn eq(&self, other: &ProvenanceTableRow) -> bool {
self.id == other.id && self.timestamp == other.timestamp && self.record == other.record
}
}

impl PartialEq<ProvenanceTableRowView<'_>> for ProvenanceTableRow {
fn eq(&self, other: &ProvenanceTableRowView) -> bool {
self.id == other.id && self.timestamp == other.timestamp && self.record == other.record
}
}

impl<'a> streaming_iterator::StreamingIterator for ProvenanceTableRowView<'a> {
type Item = Self;

Expand Down Expand Up @@ -285,8 +305,6 @@ impl OwnedProvenanceTable {
mod test_provenances {
use streaming_iterator::StreamingIterator;

use super::*;

#[test]
fn test_empty_record_string() {
// check for tables...
Expand Down Expand Up @@ -330,6 +348,9 @@ mod test_provenances {
for i in [0, 1] {
if let Some(row) = lending_iter.next() {
assert_eq!(row.record, &records[i]);
let owned_row = tables.provenances().row(i as i32).unwrap();
assert_eq!(row, &owned_row);
assert_eq!(&owned_row, row);
}
}
}
Expand Down