Expand description
Arithmetic checking and numeric conversion helpers.
Exported macros separate recoverable, expected, and prevalidated arithmetic. Conversion helpers centralize errors, panics, and deliberate truncation.
Re-exportsยง
use std::num::NonZeroUsize;๐use std::sync::atomic::AtomicU64;๐use std::sync::atomic::Ordering;๐use ruma::UInt;๐pub use self::expect_into::ExpectInto;pub use self::expected::Expected;pub use self::tried::Tried;use crate::Err;๐use crate::Error;๐use crate::Result;๐use crate::debug::type_name;๐use crate::err;๐
Modulesยง
- expect_
into ๐ - expected ๐
- tried ๐
Macrosยง
- checked_
ops - Transforms arithmetic expressions into checked operations.
Constantsยง
- USIZE_
MAX_ ๐EXCLUSIVE
Functionsยง
- effective_
cap - Combines per-call and configuration concurrency caps.
- expect_
into - Converts a value with
TryFromand panics if conversion fails. - fetch_
add_ usize - Adds a
usizecount to an atomicu64counter, saturating the count atu64::MAX. - ruma_
from_ u64 - Converts a
u64to a Matrix unsigned integer. - ruma_
from_ usize - Converts a
usizeto a Matrix unsigned integer. - ruma_
from_ usize_ saturating - Converts a
usizeto a Matrix unsigned integer, saturating at the largest value [UInt] supports. - try_
into - Converts a value with
TryFromand maps failure to an arithmetic error. - u64_
from_ i64_ saturating - Converts an
i64tou64, saturating at zero. - u64_
from_ u128_ saturating - Converts a
u128tou64, saturating atu64::MAX. - u64_
from_ usize_ saturating - Converts a
usizetou64, saturating atu64::MAX. - usize_
from_ f64 - Converts a representable nonnegative
f64tousizeby truncating toward zero. - usize_
from_ ruma - Converts a Matrix unsigned integer to
usize. - usize_
from_ ruma_ bounded - Converts a Matrix unsigned integer to a bounded
usize. - usize_
from_ u64_ truncated - Converts a
u64tousizewith deliberate truncation when necessary.