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

Method tuple

crates/vm/src/protocol/sequence.rs:318–328  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

316 }
317
318 pub fn tuple(&self, vm: &VirtualMachine) -> PyResult<PyTupleRef> {
319 if let Some(tuple) = self.obj.downcast_ref_if_exact::<PyTuple>(vm) {
320 Ok(tuple.to_owned())
321 } else if let Some(list) = self.obj.downcast_ref_if_exact::<PyList>(vm) {
322 Ok(vm.ctx.new_tuple(list.borrow_vec().to_vec()))
323 } else {
324 let iter = self.obj.to_owned().get_iter(vm)?;
325 let iter = iter.iter(vm)?;
326 Ok(vm.ctx.new_tuple(iter.try_collect()?))
327 }
328 }
329
330 pub fn list(&self, vm: &VirtualMachine) -> PyResult<PyListRef> {
331 let list = vm.ctx.new_list(self.obj.try_to_value(vm)?);

Callers

nothing calls this directly

Calls 6

to_vecMethod · 0.80
borrow_vecMethod · 0.80
get_iterMethod · 0.80
to_ownedMethod · 0.45
new_tupleMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected