forked from Rust-related/RustPython
SImpler usize
This commit is contained in:
@@ -122,17 +122,13 @@ fn re_sub(
|
||||
pattern: PyStringRef,
|
||||
repl: PyStringRef,
|
||||
string: PyStringRef,
|
||||
count: OptionalArg<PyIntRef>,
|
||||
count: OptionalArg<usize>,
|
||||
flags: OptionalArg<PyIntRef>,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult {
|
||||
let flags = extract_flags(flags);
|
||||
let regex = make_regex(vm, pattern.as_str(), flags)?;
|
||||
let limit = count
|
||||
.into_option()
|
||||
.map(|i| usize::try_from_object(vm, i.into_object()))
|
||||
.transpose()?
|
||||
.unwrap_or(0);
|
||||
let limit = count.unwrap_or(0);
|
||||
do_sub(vm, ®ex, repl, string, limit)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user