Skip to content

Commit fccb4d6

Browse files
committed
Simplify __doc__ initializing
1 parent 4bf5644 commit fccb4d6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

vm/src/builtins/classmethod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ impl Constructor for PyClassMethod {
7575
.into_ref_with_type(vm, cls)?;
7676
let obj = PyObjectRef::from(result);
7777

78-
match doc {
79-
Err(_) => None,
80-
Ok(doc) => Some(obj.set_attr("__doc__", doc, vm)),
81-
};
78+
if let Ok(doc) = doc {
79+
obj.set_attr("__doc__", doc, vm)?;
80+
}
8281

8382
Ok(obj)
8483
}

vm/src/builtins/staticmethod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ impl Constructor for PyStaticMethod {
4646
let result = PyStaticMethod { callable }.into_ref_with_type(vm, cls)?;
4747
let obj = PyObjectRef::from(result);
4848

49-
match doc {
50-
Err(_) => None,
51-
Ok(doc) => Some(obj.set_attr("__doc__", doc, vm)),
52-
};
49+
if let Ok(doc) = doc {
50+
obj.set_attr("__doc__", doc, vm)?;
51+
}
5352

5453
Ok(obj)
5554
}

0 commit comments

Comments
 (0)