diff --git a/src/alt.rs b/src/alt.rs index 3b3c0c6..4afb7f0 100644 --- a/src/alt.rs +++ b/src/alt.rs @@ -137,7 +137,8 @@ impl LandmarkBestSet<'_> { results.reverse(); self.best_landmarks.clear(); - for result in results[..self.best_size].iter() { + + for result in results[..(self.best_size.min(results.len()))].iter() { self.best_landmarks.push(result.0); } }