| 319 | } |
| 320 | |
| 321 | fn py_partition<'a, F, S>( |
| 322 | &'a self, |
| 323 | sub: &Self, |
| 324 | split: F, |
| 325 | vm: &VirtualMachine, |
| 326 | ) -> PyResult<(Self::Container, bool, Self::Container)> |
| 327 | where |
| 328 | F: Fn() -> S, |
| 329 | S: core::iter::Iterator<Item = &'a Self>, |
| 330 | { |
| 331 | if sub.is_empty() { |
| 332 | return Err(vm.new_value_error("empty separator")); |
| 333 | } |
| 334 | |
| 335 | let mut sp = split(); |
| 336 | let front = sp.next().unwrap().to_container(); |
| 337 | let (has_mid, back) = if let Some(back) = sp.next() { |
| 338 | (true, back.to_container()) |
| 339 | } else { |
| 340 | (false, Self::Container::new()) |
| 341 | }; |
| 342 | Ok((front, has_mid, back)) |
| 343 | } |
| 344 | |
| 345 | fn py_removeprefix<FC>(&self, prefix: &Self, prefix_len: usize, is_prefix: FC) -> &Self |
| 346 | where |