Skip to content

Commit 05ce6f8

Browse files
committed
fix formatting issues
1 parent 108519a commit 05ce6f8

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

vm/src/stdlib/itertools.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod decl {
1818
VirtualMachine,
1919
};
2020
use crossbeam_utils::atomic::AtomicCell;
21+
use num_bigint::BigInt;
2122
use num_traits::{Signed, ToPrimitive};
2223
use std::fmt;
2324

@@ -42,7 +43,7 @@ mod decl {
4243
.map(Into::into)
4344
}
4445

45-
#[pyclassmethod]
46+
#[pyclassmethod]
4647
fn from_iterable(
4748
cls: PyTypeRef,
4849
source: PyObjectRef,
@@ -64,16 +65,17 @@ mod decl {
6465
fn reduce(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyTupleRef> {
6566
let source = zelf.source.read().clone();
6667
let active = zelf.active.read().clone();
68+
let cls = zelf.class().clone();
6769
match source {
6870
Some(source) => {
6971
match active {
7072
Some(active) => {
71-
Ok(vm.new_tuple((zelf.class().clone(), vm.ctx.empty_tuple.clone(), (source, active))))
73+
Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone(), (source, active))))
7274
},
73-
None => Ok(vm.new_tuple((zelf.class().clone(), vm.ctx.empty_tuple.clone(), (source, ))))
75+
None => Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone(), (source, ))))
7476
}
7577
},
76-
None => Ok(vm.new_tuple((zelf.class().clone(), vm.ctx.empty_tuple.clone())))
78+
None => Ok(vm.new_tuple((cls, vm.ctx.empty_tuple.clone())))
7779
}
7880
}
7981
}
@@ -163,7 +165,7 @@ mod decl {
163165
#[pymethod(magic)]
164166
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyIter, PyIter)) {
165167
(
166-
zelf.class().to_owned(),
168+
zelf.class().clone(),
167169
(zelf.data.clone(), zelf.selectors.clone()),
168170
)
169171
}
@@ -234,7 +236,7 @@ mod decl {
234236
// return Py_BuildValue("0(00)", Py_TYPE(lz), lz->long_cnt, lz->long_step);
235237
#[pymethod(magic)]
236238
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef,)) {
237-
(zelf.class().to_owned(), (zelf.cur.read().clone(),))
239+
(zelf.class().clone(), (zelf.cur.read().clone(),))
238240
}
239241

240242
#[pymethod(magic)]
@@ -359,7 +361,7 @@ mod decl {
359361

360362
#[pymethod(magic)]
361363
fn reduce(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyTupleRef> {
362-
let cls = zelf.class().to_owned();
364+
let cls = zelf.class().clone();
363365
Ok(match zelf.times {
364366
Some(ref times) => vm.new_tuple((cls, (zelf.object.clone(), *times.read()))),
365367
None => vm.new_tuple((cls, (zelf.object.clone(),))),
@@ -426,7 +428,7 @@ mod decl {
426428
#[pymethod(magic)]
427429
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter)) {
428430
(
429-
zelf.class().to_owned(),
431+
zelf.class().clone(),
430432
(zelf.function.clone(), zelf.iterable.clone()),
431433
)
432434
}
@@ -487,11 +489,11 @@ mod decl {
487489
#[pyclass(with(IterNext, Constructor), flags(BASETYPE))]
488490
impl PyItertoolsTakewhile {
489491
#[pymethod(magic)]
490-
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter), u32) {
492+
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter), BigInt) {
491493
(
492-
zelf.class().to_owned(),
494+
zelf.class().clone(),
493495
(zelf.predicate.clone(), zelf.iterable.clone()),
494-
zelf.stop_flag.load() as _,
496+
(if zelf.stop_flag.load() { 1 } else { 0 }).into(),
495497
)
496498
}
497499
#[pymethod(magic)]
@@ -568,11 +570,11 @@ mod decl {
568570
#[pyclass(with(IterNext, Constructor), flags(BASETYPE))]
569571
impl PyItertoolsDropwhile {
570572
#[pymethod(magic)]
571-
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter), u32) {
573+
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter), BigInt) {
572574
(
573-
zelf.class().to_owned(),
575+
zelf.class().clone(),
574576
(zelf.predicate.clone().into(), zelf.iterable.clone()),
575-
(zelf.start_flag.load() as _),
577+
(if zelf.start_flag.load() { 1 } else { 0 }).into(),
576578
)
577579
}
578580
#[pymethod(magic)]
@@ -965,7 +967,7 @@ mod decl {
965967
#[pymethod(magic)]
966968
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter)) {
967969
(
968-
zelf.class().to_owned(),
970+
zelf.class().clone(),
969971
(zelf.predicate.clone(), zelf.iterable.clone()),
970972
)
971973
}
@@ -1453,7 +1455,7 @@ mod decl {
14531455
// Increment the current index which we know is not at its
14541456
// maximum. Then set all to the right to the same value.
14551457
for j in idx as usize..r {
1456-
indices[j] = index;
1458+
indices[j as usize] = index as usize;
14571459
}
14581460
}
14591461

0 commit comments

Comments
 (0)