Skip to main content

Module math

Module math 

Source
Expand description

Arithmetic checking and numeric conversion helpers.

Exported macros separate recoverable, expected, and prevalidated arithmetic. Conversion helpers centralize errors, panics, and deliberate truncation.

Modulesยง

expect_into ๐Ÿ”’
expected ๐Ÿ”’
tried ๐Ÿ”’

Macrosยง

checked_ops
Transforms arithmetic expressions into checked operations.

Constantsยง

USIZE_MAX_EXCLUSIVE ๐Ÿ”’

Traitsยง

ExpectInto
Converts values with TryFrom and panics on failure.
Expected
Adds checked arithmetic methods that panic on failure.
Tried
Adds checked arithmetic methods that return a Result.

Functionsยง

expect_into
Converts a value with TryFrom and panics if conversion fails.
ruma_from_u64
Converts a u64 to a Matrix unsigned integer.
ruma_from_usize
Converts a usize to a Matrix unsigned integer.
try_into
Converts a value with TryFrom and maps failure to an arithmetic error.
usize_from_f64
Converts a representable nonnegative f64 to usize by truncating toward zero.
usize_from_ruma
Converts a Matrix unsigned integer to usize.
usize_from_u64_truncated
Converts a u64 to usize with deliberate truncation when necessary.