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

Method group

crates/stdlib/src/re.rs:416–433  ·  view source on GitHub ↗
(&self, groups: PosArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

414
415 #[pymethod]
416 fn group(&self, groups: PosArgs, vm: &VirtualMachine) -> PyResult {
417 let mut groups = groups.into_vec();
418 match groups.len() {
419 0 => Ok(self
420 .subgroup(self.captures[0].clone().unwrap())
421 .to_pyobject(vm)),
422 1 => self
423 .get_group(groups.pop().unwrap(), vm)
424 .map(|g| g.to_pyobject(vm)),
425 _ => {
426 let output: Result<Vec<_>, _> = groups
427 .into_iter()
428 .map(|id| self.get_group(id, vm).map(|g| g.to_pyobject(vm)))
429 .collect();
430 Ok(vm.ctx.new_tuple(output?)).into()
431 }
432 }
433 }
434
435 #[pymethod]
436 fn groups(&self, default: OptionalArg, vm: &VirtualMachine) -> PyTupleRef {

Callers 1

generate_tests.pyFile · 0.45

Calls 12

get_groupMethod · 0.80
collectMethod · 0.80
into_vecMethod · 0.45
lenMethod · 0.45
to_pyobjectMethod · 0.45
subgroupMethod · 0.45
unwrapMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
popMethod · 0.45
into_iterMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected