Skip to content
Merged
Changes from all commits
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
18 changes: 18 additions & 0 deletions arrow-buffer/src/buffer/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ impl<T: ArrowNativeType> PartialEq<ScalarBuffer<T>> for Vec<T> {
}
}

/// If T implements Eq, then so does ScalarBuffer.
impl<T: ArrowNativeType + Eq> Eq for ScalarBuffer<T> {}

#[cfg(test)]
mod tests {
use std::{ptr::NonNull, sync::Arc};
Expand Down Expand Up @@ -342,4 +345,19 @@ mod tests {
assert_eq!(vec, input.as_slice());
assert_ne!(vec.as_ptr(), input.as_ptr());
}

#[test]
fn scalar_buffer_impl_eq() {
fn are_equal<T: Eq>(a: &T, b: &T) -> bool {
a.eq(b)
}

assert!(
are_equal(
&ScalarBuffer::<i16>::from(vec![23]),
&ScalarBuffer::<i16>::from(vec![23])
),
"ScalarBuffer should implement Eq if the inner type does"
);
}
}
Loading