1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

expr: clean up conversion from bigint to usize

This commit is contained in:
Terts Diepraam 2023-12-14 16:35:56 +01:00
parent 3bf966df56
commit 7f23faf899

View file

@ -294,12 +294,14 @@ impl AstNode {
let pos = pos
.eval()?
.eval_as_bigint()
.map_or(0.into(), |n| n.to_usize())
.ok()
.and_then(|n| n.to_usize())
.unwrap_or(0);
let length = length
.eval()?
.eval_as_bigint()
.map_or(0.into(), |n| n.to_usize())
.ok()
.and_then(|n| n.to_usize())
.unwrap_or(0);
let (Some(pos), Some(_)) = (pos.checked_sub(1), length.checked_sub(1)) else {