| 389 | } |
| 390 | |
| 391 | fn get_bounds( |
| 392 | &self, |
| 393 | id: PyObjectRef, |
| 394 | vm: &VirtualMachine, |
| 395 | ) -> PyResult<Option<Range<usize>>> { |
| 396 | match_class!(match id { |
| 397 | i @ PyInt => { |
| 398 | let i = usize::try_from_object(vm, i.into())?; |
| 399 | let capture = self |
| 400 | .captures |
| 401 | .get(i) |
| 402 | .ok_or_else(|| vm.new_index_error("No such group".to_owned()))?; |
| 403 | Ok(capture.clone()) |
| 404 | } |
| 405 | _s @ PyStr => unimplemented!(), |
| 406 | _ => Err(vm.new_index_error("No such group".to_owned())), |
| 407 | }) |
| 408 | } |
| 409 | |
| 410 | fn get_group(&self, id: PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<String>> { |
| 411 | let bounds = self.get_bounds(id, vm)?; |