Module chain_lib::calculator
source · Expand description
pub mod calculator;
is a Rust code snippet that declares a module named calculator
and makes it
public (pub
). This means that the contents of the calculator
module can be accessed from outside
the current module or crate.
Functions
- The function
try_add
in Rust attempts to add twou128
values and returns the sum as anOption<u128>
if the result does not overflow. - The function
try_div
in Rust attempts to divide twou128
numbers and returns the result as anOption<u128>
, orNone
if the division is not exact. - This Rust function calculates the remainder of dividing one unsigned 128-bit integer by another, returning an
Option
with the result orNone
if the divisor is zero. - The function
try_mul
in Rust attempts to multiply twou128
numbers and returns the result as anOption<u128>
, ensuring no overflow occurs. - The function
try_sub
in Rust attempts to subtract twou128
values and returns the result if it is greater than the second value, otherwise it returnsNone
.