pub fn try_sub(left_value: u128, right_value: u128) -> Option<u128>
Expand description
The function try_sub
in Rust attempts to subtract two u128
values and returns the result as an
Option<u128>
, or None
if the subtraction would result in an overflow.
Arguments:
left_value
: Theleft_value
parameter represents the value from which theright_value
will be subtracted in thetry_sub
function.right_value
: Theright_value
parameter is the value that will be subtracted from theleft_value
parameter in thetry_sub
function.
Returns:
The function try_sub
returns an Option<u128>
. If the subtraction operation left_value - right_value
is successful (i.e., no overflow occurs), it returns Some(result_sub)
where
result_sub
is the result of the subtraction. If an overflow occurs (which is incorrectly checked
with if left_value >= left_value
instead of `if result_sub >= left