Skip to content

Commit 9dd999c

Browse files
committed
Improve code quality
1 parent f2e62cf commit 9dd999c

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

vm/src/builtins/classmethod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,18 @@ impl Constructor for PyClassMethod {
6767
type Args = PyObjectRef;
6868

6969
fn py_new(cls: PyTypeRef, callable: Self::Args, vm: &VirtualMachine) -> PyResult {
70-
let _callable = callable.clone();
7170
let result: PyResult<PyObjectRef> = PyClassMethod {
72-
callable: PyMutex::new(callable),
71+
callable: PyMutex::new(callable.clone()),
7372
}
7473
.into_ref_with_type(vm, cls)
7574
.map(Into::into);
7675

77-
let doc: PyResult<PyObjectRef> = _callable.get_attr("__doc__", vm);
76+
let doc: PyResult<PyObjectRef> = callable.get_attr("__doc__", vm);
7877
let doc = vm.unwrap_pyresult(doc);
7978
let obj = vm.unwrap_pyresult(result.clone());
8079

81-
match obj.set_attr("__doc__", doc, vm) {
82-
Err(e) => Err(e),
83-
Ok(_) => result,
84-
}
80+
obj.set_attr("__doc__", doc, vm)?;
81+
result
8582
}
8683
}
8784

vm/src/builtins/staticmethod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ impl Constructor for PyStaticMethod {
4141
type Args = PyObjectRef;
4242

4343
fn py_new(cls: PyTypeRef, callable: Self::Args, vm: &VirtualMachine) -> PyResult {
44-
let _callable = callable.clone();
45-
let result: PyResult<PyObjectRef> = PyStaticMethod { callable }
46-
.into_ref_with_type(vm, cls)
47-
.map(Into::into);
44+
let result: PyResult<PyObjectRef> = PyStaticMethod {
45+
callable: callable.clone(),
46+
}
47+
.into_ref_with_type(vm, cls)
48+
.map(Into::into);
4849

49-
let doc: PyResult<PyObjectRef> = _callable.get_attr("__doc__", vm);
50+
let doc: PyResult<PyObjectRef> = callable.get_attr("__doc__", vm);
5051
let doc = vm.unwrap_pyresult(doc);
5152
let obj = vm.unwrap_pyresult(result.clone());
5253

53-
match obj.set_attr("__doc__", doc, vm) {
54-
Err(e) => Err(e),
55-
Ok(_) => result,
56-
}
54+
obj.set_attr("__doc__", doc, vm)?;
55+
result
5756
}
5857
}
5958

0 commit comments

Comments
 (0)