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

Method init

crates/vm/src/builtins/list.rs:475–483  ·  view source on GitHub ↗
(zelf: PyRef<Self>, iterable: Self::Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

473 type Args = OptionalArg<PyObjectRef>;
474
475 fn init(zelf: PyRef<Self>, iterable: Self::Args, vm: &VirtualMachine) -> PyResult<()> {
476 let mut elements = if let OptionalArg::Present(iterable) = iterable {
477 iterable.try_to_value(vm)?
478 } else {
479 vec![]
480 };
481 core::mem::swap(zelf.borrow_vec_mut().deref_mut(), &mut elements);
482 Ok(())
483 }
484}
485
486impl AsMapping for PyList {

Callers

nothing calls this directly

Calls 3

try_to_valueMethod · 0.80
borrow_vec_mutMethod · 0.80
deref_mutMethod · 0.45

Tested by

no test coverage detected