| 1114 | #[pyclass(with(IterNext, Iterable, Constructor))] |
| 1115 | impl PyItertoolsProduct { |
| 1116 | fn update_idxs(&self, mut idxs: PyRwLockWriteGuard<'_, Vec<usize>>) { |
| 1117 | if idxs.is_empty() { |
| 1118 | self.stop.store(true); |
| 1119 | return; |
| 1120 | } |
| 1121 | |
| 1122 | let cur = self.cur.load(); |
| 1123 | let lst_idx = &self.pools[cur].len() - 1; |
| 1124 | |
| 1125 | if idxs[cur] == lst_idx { |
| 1126 | if cur == 0 { |
| 1127 | self.stop.store(true); |
| 1128 | return; |
| 1129 | } |
| 1130 | idxs[cur] = 0; |
| 1131 | self.cur.fetch_sub(1); |
| 1132 | self.update_idxs(idxs); |
| 1133 | } else { |
| 1134 | idxs[cur] += 1; |
| 1135 | self.cur.store(idxs.len() - 1); |
| 1136 | } |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | impl SelfIter for PyItertoolsProduct {} |