Update itertools count repr

This commit is contained in:
oow214
2022-06-30 21:00:10 +09:00
parent 5786a0640c
commit 27a0d3a93a

View File

@@ -17,7 +17,7 @@ mod decl {
AsObject, Py, PyObjectRef, PyPayload, PyRef, PyResult, PyWeakRef, VirtualMachine,
};
use crossbeam_utils::atomic::AtomicCell;
use num_traits::{Signed, ToPrimitive};
use num_traits::{Signed, ToPrimitive, One};
use std::fmt;
#[pyattr]
@@ -222,8 +222,8 @@ mod decl {
#[pymethod(magic)]
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
let cur = format!("{}", self.cur.read().clone().repr(vm)?);
let step = self.step.as_u32_mask().clone();
if step == 1 {
let step = self.step.as_bigint();
if step.is_one() {
return Ok(format!("count({})", cur));
}
Ok(format!("count({}, {})", cur, step.to_string()))