MCPcopy Index your code
hub / github.com/RustPython/RustPython / setitem_by_slice

Method setitem_by_slice

crates/vm/src/sliceable.rs:63–86  ·  view source on GitHub ↗
(
        &mut self,
        vm: &VirtualMachine,
        slice: SaturatedSlice,
        items: &[Self::Item],
    )

Source from the content-addressed store, hash-verified

61 }
62
63 fn setitem_by_slice(
64 &mut self,
65 vm: &VirtualMachine,
66 slice: SaturatedSlice,
67 items: &[Self::Item],
68 ) -> PyResult<()> {
69 let (range, step, slice_len) = slice.adjust_indices(self.as_ref().len());
70 if step == 1 {
71 self.do_set_range(range, items);
72 Ok(())
73 } else if slice_len == items.len() {
74 self.do_set_indexes(
75 SaturatedSliceIter::from_adjust_indices(range, step, slice_len),
76 items,
77 );
78 Ok(())
79 } else {
80 Err(vm.new_value_error(format!(
81 "attempt to assign sequence of size {} to extended slice of size {}",
82 items.len(),
83 slice_len
84 )))
85 }
86 }
87
88 fn delitem_by_index(&mut self, vm: &VirtualMachine, index: isize) -> PyResult<()> {
89 let pos = self

Callers

nothing calls this directly

Implementers 1

sliceable.rscrates/vm/src/sliceable.rs

Calls 6

adjust_indicesMethod · 0.80
do_set_rangeMethod · 0.80
do_set_indexesMethod · 0.80
ErrClass · 0.50
lenMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected