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

Method concat

crates/vm/src/builtins/list.rs:201–212  ·  view source on GitHub ↗
(&self, other: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

199 }
200
201 fn concat(&self, other: &PyObject, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
202 let other = other.downcast_ref::<Self>().ok_or_else(|| {
203 vm.new_type_error(format!(
204 "Cannot add {} and {}",
205 Self::class(&vm.ctx).name(),
206 other.class().name()
207 ))
208 })?;
209 let mut elements = self.borrow_vec().to_vec();
210 elements.extend(other.borrow_vec().iter().cloned());
211 Ok(Self::from(elements).into_ref(&vm.ctx))
212 }
213
214 fn __add__(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
215 self.concat(&other, vm)

Callers 1

__add__Method · 0.45

Calls 6

ok_or_elseMethod · 0.80
to_vecMethod · 0.80
borrow_vecMethod · 0.80
extendMethod · 0.45
iterMethod · 0.45
into_refMethod · 0.45

Tested by

no test coverage detected