(zelf: &Py<Self>, vm: &VirtualMachine)
| 356 | |
| 357 | impl IterNext for PyStrIterator { |
| 358 | fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> { |
| 359 | let mut internal = zelf.internal.lock(); |
| 360 | |
| 361 | if let IterStatus::Active(s) = &internal.0.status { |
| 362 | let value = s.as_wtf8(); |
| 363 | |
| 364 | if internal.1 == usize::MAX { |
| 365 | if let Some((offset, ch)) = value.code_point_indices().nth(internal.0.position) { |
| 366 | internal.0.position += 1; |
| 367 | internal.1 = offset + ch.len_wtf8(); |
| 368 | return Ok(PyIterReturn::Return(ch.to_pyobject(vm))); |
| 369 | } |
| 370 | } else if let Some(value) = value.get(internal.1..) |
| 371 | && let Some(ch) = value.code_points().next() |
| 372 | { |
| 373 | internal.0.position += 1; |
| 374 | internal.1 += ch.len_wtf8(); |
| 375 | return Ok(PyIterReturn::Return(ch.to_pyobject(vm))); |
| 376 | } |
| 377 | internal.0.status = Exhausted; |
| 378 | } |
| 379 | Ok(PyIterReturn::StopIteration(None)) |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | #[derive(FromArgs)] |
no test coverage detected