mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Fix manual_map Clippy warning
This commit is contained in:
@@ -48,10 +48,8 @@ pub fn init(context: &PyContext) {
|
||||
fn to_op_complex(value: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<Complex64>> {
|
||||
let r = if let Some(complex) = value.payload_if_subclass::<PyComplex>(vm) {
|
||||
Some(complex.value)
|
||||
} else if let Some(float) = float::to_op_float(value, vm)? {
|
||||
Some(Complex64::new(float, 0.0))
|
||||
} else {
|
||||
None
|
||||
float::to_op_float(value, vm)?.map(|float| Complex64::new(float, 0.0))
|
||||
};
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
@@ -584,10 +584,10 @@ impl Iterator for DictIter {
|
||||
type Item = (PyObjectRef, PyObjectRef);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match self.dict.entries.next_entry(&mut self.position) {
|
||||
Some((key, value)) => Some((key, value)),
|
||||
None => None,
|
||||
}
|
||||
self.dict
|
||||
.entries
|
||||
.next_entry(&mut self.position)
|
||||
.map(|(key, value)| (key, value))
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
|
||||
@@ -449,15 +449,12 @@ impl PyBoundMethod {
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
|
||||
let funcname = if let Some(qname) =
|
||||
vm.get_attribute_opt(self.function.clone(), "__qualname__")?
|
||||
{
|
||||
Some(qname)
|
||||
} else if let Some(name) = vm.get_attribute_opt(self.function.clone(), "__qualname__")? {
|
||||
Some(name)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let funcname =
|
||||
if let Some(qname) = vm.get_attribute_opt(self.function.clone(), "__qualname__")? {
|
||||
Some(qname)
|
||||
} else {
|
||||
vm.get_attribute_opt(self.function.clone(), "__qualname__")?
|
||||
};
|
||||
let funcname: Option<PyStrRef> = funcname.and_then(|o| o.downcast().ok());
|
||||
Ok(format!(
|
||||
"<bound method {} of {}>",
|
||||
|
||||
@@ -439,10 +439,8 @@ impl ExecutingFrame<'_> {
|
||||
// variable is Some
|
||||
let thrower = if let Some(coro) = self.builtin_coro(coro) {
|
||||
Some(Either::A(coro))
|
||||
} else if let Some(meth) = vm.get_attribute_opt(coro.clone(), "throw")? {
|
||||
Some(Either::B(meth))
|
||||
} else {
|
||||
None
|
||||
vm.get_attribute_opt(coro.clone(), "throw")?.map(Either::B)
|
||||
};
|
||||
if let Some(thrower) = thrower {
|
||||
let ret = match thrower {
|
||||
|
||||
@@ -219,11 +219,10 @@ impl FuncArgs {
|
||||
}
|
||||
|
||||
pub fn check_kwargs_empty(&self, vm: &VirtualMachine) -> Option<PyBaseExceptionRef> {
|
||||
if let Some(k) = self.kwargs.keys().next() {
|
||||
Some(vm.new_type_error(format!("Unexpected keyword argument {}", k)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.kwargs
|
||||
.keys()
|
||||
.next()
|
||||
.map(|k| vm.new_type_error(format!("Unexpected keyword argument {}", k)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,10 +278,9 @@ mod decl {
|
||||
times: OptionalArg<PyIntRef>,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<PyRef<Self>> {
|
||||
let times = match times.into_option() {
|
||||
Some(int) => Some(PyRwLock::new(int.borrow_value().clone())),
|
||||
None => None,
|
||||
};
|
||||
let times = times
|
||||
.into_option()
|
||||
.map(|int| PyRwLock::new(int.borrow_value().clone()));
|
||||
|
||||
PyItertoolsRepeat { object, times }.into_ref_with_type(vm, cls)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user