Function try_sub

Source
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: The left_value parameter represents the value from which the right_value will be subtracted in the try_sub function.
  • right_value: The right_value parameter is the value that will be subtracted from the left_value parameter in the try_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