Skip to content

Commit 30c8e47

Browse files
committed
style: rustfmt
1 parent d96e0ec commit 30c8e47

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

vm/src/exceptions.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ impl ExceptionZoo {
135135

136136
let overflow_error =
137137
create_type("OverflowError", &type_type, &arithmetic_error, &dict_type);
138-
let zero_division_error =
139-
create_type("ZeroDivisionError", &type_type, &arithmetic_error, &dict_type);
138+
let zero_division_error = create_type(
139+
"ZeroDivisionError",
140+
&type_type,
141+
&arithmetic_error,
142+
&dict_type,
143+
);
140144

141145
let module_not_found_error =
142146
create_type("ModuleNotFoundError", &type_type, &import_error, &dict_type);

vm/src/obj/objint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,13 @@ fn int_truediv(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
371371
required = [(i, Some(vm.ctx.int_type())), (i2, None)]
372372
);
373373

374-
let v1 = get_value(i).to_f64()
374+
let v1 = get_value(i)
375+
.to_f64()
375376
.ok_or_else(|| vm.new_overflow_error("int too large to convert to float".to_string()))?;
376377

377378
let v2 = if objtype::isinstance(i2, &vm.ctx.int_type()) {
378-
get_value(i2).to_f64()
379+
get_value(i2)
380+
.to_f64()
379381
.ok_or_else(|| vm.new_overflow_error("int too large to convert to float".to_string()))?
380382
} else if objtype::isinstance(i2, &vm.ctx.float_type()) {
381383
objfloat::get_value(i2)
@@ -386,9 +388,7 @@ fn int_truediv(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
386388
if v2 == 0.0 {
387389
Err(vm.new_zero_division_error("integer division by zero".to_string()))
388390
} else {
389-
Ok(vm
390-
.ctx
391-
.new_float(v1 / v2))
391+
Ok(vm.ctx.new_float(v1 / v2))
392392
}
393393
}
394394

vm/src/obj/objrange.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::super::pyobject::{
44
use super::super::vm::VirtualMachine;
55
use super::objint;
66
use super::objtype;
7-
use num_bigint::{BigInt, ToBigInt, Sign};
7+
use num_bigint::{BigInt, Sign, ToBigInt};
88
use num_traits::{One, Signed, ToPrimitive, Zero};
99

1010
#[derive(Debug, Clone)]
@@ -20,10 +20,14 @@ impl RangeType {
2020
#[inline]
2121
pub fn try_len(&self) -> Option<usize> {
2222
match self.step.sign() {
23-
Sign::Plus if self.start < self.end =>
24-
((&self.end - &self.start - 1usize) / &self.step).to_usize().map(|sz| sz + 1),
25-
Sign::Minus if self.start > self.end =>
26-
((&self.start - &self.end - 1usize) / (-&self.step)).to_usize().map(|sz| sz + 1),
23+
Sign::Plus if self.start < self.end => ((&self.end - &self.start - 1usize)
24+
/ &self.step)
25+
.to_usize()
26+
.map(|sz| sz + 1),
27+
Sign::Minus if self.start > self.end => ((&self.start - &self.end - 1usize)
28+
/ (-&self.step))
29+
.to_usize()
30+
.map(|sz| sz + 1),
2731
_ => Some(0),
2832
}
2933
}
@@ -56,7 +60,7 @@ impl RangeType {
5660
None
5761
}
5862
}
59-
63+
6064
#[inline]
6165
pub fn repr(&self) -> String {
6266
if self.step == BigInt::one() {

0 commit comments

Comments
 (0)