Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions crates/stdlib/src/bisect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ mod _bisect {
}

#[pyfunction]
#[expect(
clippy::redundant_clone,
reason = "keep the original arguments alive until the insert result is released"
)]
fn insort_left(BisectArgs { a, x, lo, hi, key }: BisectArgs, vm: &VirtualMachine) -> PyResult {
// The search runs on the key, the insert has to put back the item itself.
let needle = match key {
Expand All @@ -117,14 +121,20 @@ mod _bisect {
x: needle,
lo,
hi,
key,
key: key.clone(),
},
vm,
)?;
vm.call_method(&a, "insert", (index, x))
let result = vm.call_method(&a, "insert", (index, x.clone()))?;
drop(result);
Ok(vm.ctx.none())
}

#[pyfunction]
#[expect(
clippy::redundant_clone,
reason = "keep the original arguments alive until the insert result is released"
)]
fn insort_right(BisectArgs { a, x, lo, hi, key }: BisectArgs, vm: &VirtualMachine) -> PyResult {
// The search runs on the key, the insert has to put back the item itself.
let needle = match key {
Expand All @@ -137,10 +147,12 @@ mod _bisect {
x: needle,
lo,
hi,
key,
key: key.clone(),
},
vm,
)?;
vm.call_method(&a, "insert", (index, x))
let result = vm.call_method(&a, "insert", (index, x.clone()))?;
drop(result);
Ok(vm.ctx.none())
}
}
Loading