Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Standard Library Reference

Cross-target helpers live under std::. Bare calls such as min(a, b) or sha256(data) are rejected (V49) — use the qualified forms. A std:: name outside the functions listed here is rejected on both targets (E25).

Authoritative tables also live in cambrian-lang docs/STDLIB.md.

std::math

FunctionRole
min, max, minmaxOrdering
abs, signSign
clampRange clamp
muldiv, muldivmodWidening multiply-then-divide (muldivmod returns quotient and remainder; EVM only — no Lean lowering, L16)
divmod, divc, divrDivision variants
modpow2, powPowers

std::str

FunctionRole
parse_u8, parse_u16, parse_u32, parse_u64, parse_u128, parse_U256(s: String, radix) -> Option<uN>
parse_i8, parse_i16, parse_i32, parse_i64, parse_i128(s: String, radix) -> Option<iN>
parse_uint / parse_intAliases of parse_u64 / parse_i64
formatRust-style format string: std::str::format("{:06}", x)

A parse returns none on an empty string, an invalid digit, or a bad radix.

String ↔ number conversion is never implicit (V50): use parse_* / format.

pure fn parse_or_zero(s: String) -> u64 {
    match std::str::parse_u64(s, 10) {
        some(n) => n,
        none => 0,
    }
}

std::crypto

FunctionRole
sha256SHA-256 digest of bytes / String. EVM only — no Lean lowering (L13)

A user pure fn may reuse a std:: function name (min, pow, …): a bare min(a, b) then calls the user function, while std::math::min(a, b) always calls the standard library. V49 fires on a bare call only when no user function of that name exists.

NamespaceDocs
msg::Message Context
sys::System Context
evm::EVM Intrinsics