Expand description
Bundled Bop standard library (use std.math, std.json,
std.collections, std.iter, std.string, std.result,
std.test). Feature-gated behind bop-std (on by default).
The module is named stdlib rather than std specifically
to avoid shadowing Rust’s own ::std when a consumer does
use bop::* (or when anything in the crate’s own tests
does use super::*). bop::stdlib::resolve(...) is the
public entry point.
Bundled Bop standard library modules, resolved by name.
Each .bop file under src/modules/ is baked into the binary
as an &'static str via include_str!. When a Bop script
does use std.math, the engine asks its BopHost to
resolve the module — embedders route that call to
[resolve], which returns the bundled source text.
Gated behind the bop-std feature (on by default). Disable
with default-features = false when you want a truly minimal
core with no bundled modules:
bop-lang = { version = "0.3", default-features = false }Available modules:
std.math— numeric constants (PI,E,TAU) and helpers that don’t fit on a numeric receiver (clamp,factorial,gcd, …)std.iter— functional helpers on arrays (map,filter,reduce,sum,find, …)std.string— string helpers that didn’t fit the method-on-string pattern (pad_left,pad_right,chars, …)std.test—assert,assert_eq,assert_nearplus a tiny test-runnerstd.collections—Set,Queue,Stackas struct types with value-semantic methods (s = s.push(v)etc.)std.json—parse(text)/stringify(value). Pure Bop implementation; adequate for scripting workloads.
Result combinators (is_ok, unwrap, map, and_then,
…) used to live in std.result but are now methods on the
built-in Result type — always available without a use.
See methods::result_method.
Constants§
- MODULES
- Every module name this crate can resolve. Useful for docs, diagnostics, or a “did you mean…” suggestion in error paths.
Functions§
- resolve
- Map a
std.*module name to its bundled Bop source.