mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Use lock in both index and remove operation.
This commit is contained in:
1 parent
70294bca50
commit
5fa0abdfef
1 file changed
+2
-2
@@ -300,8 +300,8 @@ impl PyList {
|
||||
|
||||
if let Some(index) = index.into() {
|
||||
// defer delete out of borrow
|
||||
let mut elements = self.borrow_vec_mut();
|
||||
Ok((index < elements.len()).then(move || elements.remove(index)))
|
||||
let is_inside_range = index < self.borrow_vec().len();
|
||||
Ok(is_inside_range.then(|| self.borrow_vec_mut().remove(index)))
|
||||
} else {
|
||||
Err(vm.new_value_error(format!("'{}' is not in list", needle.str(vm)?)))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user