fix: Clamp the document range requested

This commit is contained in:
Clément Renault 2018-10-17 16:59:39 +02:00
parent 37c709c9a9
commit af91bfa11f

View File

@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::hash::Hash; use std::hash::Hash;
use std::ops::Range; use std::ops::Range;
use std::rc::Rc; use std::rc::Rc;
use std::{mem, vec}; use std::{mem, vec, cmp};
use fnv::FnvHashMap; use fnv::FnvHashMap;
use fst::Streamer; use fst::Streamer;
@ -92,6 +92,10 @@ where C: Criterion
} }
} }
let range = Range {
start: cmp::min(range.start, documents.len()),
end: cmp::min(range.end, documents.len()),
};
documents[range].to_vec() documents[range].to_vec()
} }