add safety check

This commit is contained in:
yuni 2024-04-14 03:37:33 +02:00
parent 86217d121e
commit dad7fc8fc4

View file

@ -188,11 +188,12 @@ impl ChatDB {
} }
} }
for (index, label) in changes { for (index, label) in changes {
vector.remove(index); if index < vector.len() {
vector.splice(index..index, include_db[&label].iter().cloned()); vector.remove(index);
vector.splice(index..index, include_db[&label].iter().cloned());
}
} }
} }
return;
} }
pub fn get_chat_by_id(&self, id: &String) -> Result<usize, String> { pub fn get_chat_by_id(&self, id: &String) -> Result<usize, String> {