mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
expr: clean up conversion from bigint to usize
This commit is contained in:
parent
3bf966df56
commit
7f23faf899
1 changed files with 4 additions and 2 deletions
|
@ -294,12 +294,14 @@ impl AstNode {
|
||||||
let pos = pos
|
let pos = pos
|
||||||
.eval()?
|
.eval()?
|
||||||
.eval_as_bigint()
|
.eval_as_bigint()
|
||||||
.map_or(0.into(), |n| n.to_usize())
|
.ok()
|
||||||
|
.and_then(|n| n.to_usize())
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
let length = length
|
let length = length
|
||||||
.eval()?
|
.eval()?
|
||||||
.eval_as_bigint()
|
.eval_as_bigint()
|
||||||
.map_or(0.into(), |n| n.to_usize())
|
.ok()
|
||||||
|
.and_then(|n| n.to_usize())
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
let (Some(pos), Some(_)) = (pos.checked_sub(1), length.checked_sub(1)) else {
|
let (Some(pos), Some(_)) = (pos.checked_sub(1), length.checked_sub(1)) else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue