forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutil.rs
More file actions
36 lines (31 loc) · 745 Bytes
/
util.rs
File metadata and controls
36 lines (31 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/// Calculates the product of all values in the given slice.
pub fn slice_product(slice: &[usize]) -> usize {
let mut result = 1;
for val in slice {
result *= *val;
}
result
}
/*
/// Returns the highest value in a slice.
pub fn max_in_slice<O: Ord + Copy>(slice: &[O]) -> O {
assert!(!slice.is_empty());
let mut highest = slice[0];
for val in slice {
if *val > highest {
highest = *val;
}
}
highest
}*/
/// Returns the lowest value in a slice.
pub fn min_in_slice<O: Ord + Copy>(slice: &[O]) -> O {
assert!(!slice.is_empty());
let mut lowest = slice[0];
for val in slice {
if *val < lowest {
lowest = *val;
}
}
lowest
}