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

Method concat

crates/vm/src/bytes_inner.rs:959–972  ·  view source on GitHub ↗
(&self, other: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

957 }
958
959 pub fn concat(&self, other: &PyObject, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
960 let buffer = PyBuffer::try_from_borrowed_object(vm, other)?;
961 let borrowed = buffer.as_contiguous();
962 if let Some(other) = borrowed {
963 let mut v = Vec::with_capacity(self.elements.len() + other.len());
964 v.extend_from_slice(&self.elements);
965 v.extend_from_slice(&other);
966 Ok(v)
967 } else {
968 let mut v = self.elements.clone();
969 buffer.append_to(&mut v);
970 Ok(v)
971 }
972 }
973}
974
975pub fn try_as_bytes<F, R>(obj: PyObjectRef, f: F) -> Option<R>

Callers 4

test_concatMethod · 0.45
get_addr_tupleFunction · 0.45
to_vecMethod · 0.45
decompress_innerMethod · 0.45

Calls 4

as_contiguousMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
append_toMethod · 0.45

Tested by 1

test_concatMethod · 0.36