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

Method mul

crates/vm/src/sequence.rs:100–112  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine, n: isize)

Source from the content-addressed store, hash-verified

98 Self: AsRef<[T]>,
99{
100 fn mul(&self, vm: &VirtualMachine, n: isize) -> PyResult<Vec<T>> {
101 let n = vm.check_repeat_or_overflow_error(self.as_ref().len(), n)?;
102
103 if n > 1 && core::mem::size_of_val(self.as_ref()) >= MAX_MEMORY_SIZE / n {
104 return Err(vm.new_memory_error(""));
105 }
106
107 let mut v = Vec::with_capacity(n * self.as_ref().len());
108 for _ in 0..n {
109 v.extend_from_slice(self.as_ref());
110 }
111 Ok(v)
112 }
113}
114
115impl<T: Clone> SequenceExt<T> for [T] {}

Callers

nothing calls this directly

Implementers 1

sequence.rscrates/vm/src/sequence.rs

Calls 4

ErrClass · 0.50
lenMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected