Skip to content

Commit

Permalink
simple one liner
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle committed Aug 27, 2024
1 parent 3ef782d commit 4a33294
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,9 @@ pub fn extract_i64(v: &Bound<'_, PyAny>) -> Option<i64> {
}

pub fn extract_int(v: &Bound<'_, PyAny>) -> Option<Int> {
match extract_i64(v) {
Some(i) => Some(Int::I64(i)),
None => {
if let Ok(big_int) = v.extract::<BigInt>() {
Some(Int::Big(big_int))
} else {
None
}
}
}
extract_i64(v)
.map(Int::I64)
.or_else(|| v.extract::<BigInt>().ok().map(Int::Big))
}

pub(crate) fn new_py_string<'py>(py: Python<'py>, s: &str, cache_str: StringCacheMode) -> Bound<'py, PyString> {
Expand Down

0 comments on commit 4a33294

Please sign in to comment.