mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Merge pull request #2116 from clemado1/itertools
Fix index and overflow error in itertools
This commit is contained in:
1 file changed
+2
-2
@@ -1374,7 +1374,7 @@ mod decl {
|
||||
PyItertoolsPermutations {
|
||||
pool,
|
||||
indices: PyRwLock::new((0..n).collect()),
|
||||
cycles: PyRwLock::new((0..r).map(|i| n - i).collect()),
|
||||
cycles: PyRwLock::new((0..r.min(n)).map(|i| n - i).collect()),
|
||||
result: PyRwLock::new(None),
|
||||
r: AtomicCell::new(r),
|
||||
exhausted: AtomicCell::new(r > n),
|
||||
@@ -1417,7 +1417,7 @@ mod decl {
|
||||
// rotation: indices[i:] = indices[i+1:] + indices[i:i+1]
|
||||
let index = indices[i];
|
||||
for j in i..n - 1 {
|
||||
indices[j] = indices[j + i];
|
||||
indices[j] = indices[j + 1];
|
||||
}
|
||||
indices[n - 1] = index;
|
||||
cycles[i] = n - i;
|
||||
|
||||
Reference in new issue
Block a user