Fix trivial suggestions

This commit is contained in:
Jeong YunWon
2023-04-06 00:32:47 +09:00
committed by snowapril
parent 4416b2a467
commit a4a6e8dabe
3 changed files with 13 additions and 22 deletions

View File

@@ -554,8 +554,7 @@ impl AsNumber for PyFloat {
PyFloat::number_op(a, b, float_pow, vm)
} else {
Err(vm.new_type_error(String::from(
"pow() 3rd argument not \\
allowed unless all arguments are integers",
"pow() 3rd argument not allowed unless all arguments are integers",
)))
}
}),

View File

@@ -621,10 +621,8 @@ mod builtins {
exp: y,
modulus,
} = args;
match modulus {
None => vm._pow(&x, &y, vm.ctx.none.as_object()),
Some(z) => vm._pow(&x, &y, &z),
}
let modulus = modulus.as_ref().map_or(vm.ctx.none.as_object(), |m| m);
vm._pow(&x, &y, modulus)
}
#[pyfunction]

View File

@@ -567,28 +567,22 @@ impl PyType {
}
_ if name == identifier!(ctx, __pow__) => {
toggle_subslot!(as_number, power, |a, b, c, vm| {
if vm.is_none(c) {
vm.call_special_method(a, identifier!(vm, __pow__), (b.to_owned(),))
let args = if vm.is_none(c) {
vec![b.to_owned()]
} else {
vm.call_special_method(
a,
identifier!(vm, __pow__),
(b.to_owned(), c.to_owned()),
)
}
vec![b.to_owned(), c.to_owned()]
};
vm.call_special_method(a, identifier!(vm, __pow__), args)
});
}
_ if name == identifier!(ctx, __rpow__) => {
toggle_subslot!(as_number, right_power, |a, b, c, vm| {
if vm.is_none(c) {
vm.call_special_method(b, identifier!(vm, __rpow__), (a.to_owned(),))
let args = if vm.is_none(c) {
vec![a.to_owned()]
} else {
vm.call_special_method(
b,
identifier!(vm, __rpow__),
(a.to_owned(), c.to_owned()),
)
}
vec![a.to_owned(), c.to_owned()]
};
vm.call_special_method(b, identifier!(vm, __rpow__), args)
});
}
_ if name == identifier!(ctx, __ipow__) => {