Skip to content

Commit

Permalink
cdef: enforce 8 element size for first_max_element
Browse files Browse the repository at this point in the history
  • Loading branch information
tmatth committed Sep 15, 2021
1 parent 2ec4e67 commit 2939576
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) mod rust {
///
/// Panics if `elems` is empty
#[inline]
fn first_max_element(elems: &[i32]) -> (usize, i32) {
fn first_max_element(elems: &[i32; 8]) -> (usize, i32) {
// In case of a tie, the first element must be selected.
let (max_idx, max_value) = elems
.iter()
Expand Down Expand Up @@ -307,7 +307,7 @@ pub(crate) mod rust {
fn check_max_element() {
assert_eq!(first_max_element(&[-1, -1, 1, 2, 3, 4, 6, 6]), (6, 6));
assert_eq!(first_max_element(&[-1, -1, 1, 2, 3, 4, 7, 6]), (6, 7));
assert_eq!(first_max_element(&[0, 0]), (0, 0));
assert_eq!(first_max_element(&[0, 0, 0, 0, 0, 0, 0, 0]), (0, 0));
}
}
}
Expand Down

0 comments on commit 2939576

Please sign in to comment.