mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-06 19:12:20 +00:00
Improve split function
This commit is contained in:
parent
229351b38e
commit
c8d5f00d7c
@ -37,7 +37,10 @@ fn honey_badger_split<T: Clone>(list: &Vec<T>, n: usize) -> Vec<Vec<T>> {
|
||||
let mut split_list: Vec<Vec<T>> = vec![];
|
||||
let list_length = list.len();
|
||||
for i in 0..n {
|
||||
let partition = list.get(list_length*i/n..list_length*(i+1)/n).unwrap(); // cannot go out of bounds
|
||||
let partition = match list.get(list_length*i/n..list_length*(i+1)/n) {
|
||||
Some(v) => v,
|
||||
None => unreachable!(),
|
||||
};
|
||||
split_list.push(partition.to_vec());
|
||||
}
|
||||
split_list
|
||||
|
Loading…
Reference in New Issue
Block a user