pub static STANDARD_LIBRARY: &[StdBinding]Expand description
Every builtin method whose body has moved out of Rust and into the standard library.
Twenty-nine entries, and what is not here is as informative as what is.
Result.mapError is here, and it is the only one that needed a language
change to arrive. While a callback’s arity was adapted rather than
matched, a program could write mapError { ... } with a trailing closure
naming no parameter, and no Cove body can call such a closure —
body(error) passes one argument always. ADR 0044 removed that
exception, and this row is what it bought.
Int.abs is here too now, and it is the first entry that can fail: the
least Int has no positive counterpart. It waited on
issue #258, which taught a
trap raised from inside a standard-library body to name its caller
instead of only the library’s own line — without that, moving abs
here would have moved its diagnostic out of the caller’s source along
with it.
Ten of the twenty-nine are Duration’s, and they are the first entries
that come in pairs: micros, millis, seconds, minutes, and hours
each name a method (d.millis(), the reader) and, separately, an
associated function (Duration.millis(n), the builder) — see
StdBindingKind. nanos is not among them and never will be: it is
the one primitive Duration keeps, because something has to know how a
duration is actually stored. Before this migration all six readers
shared one table-driven Rust function and so did all six builders; a
reader now divides by its unit’s constant and a builder multiplies by
it, both written once in std.duration rather than once per backend.
§Checking ADR 0043’s third condition before adding a row here
ADR 0043’s
third migration condition is that the Rust an entry deletes is
per-method: a method whose implementation is shared with others
moves nothing by moving, and counting schema entries instead of
implementations is the mistake that ADR corrects — which is exactly what
made Duration wait until its shared table-driven function could be
deleted outright rather than merely bypassed for five of its six units.
The check is: delete the dispatch arm in cove-runtime’s
vm::builtins that calls the Rust function, leave the function itself
defined, and run
cargo clippy --workspace --all-targets --profile checked -- -D warnings.
If the condition holds, clippy reports the now-unreachable function as
dead code and the build fails; a build that stays green says the
function still has another caller, which is exactly the shared-Rust case
the condition rules out.
This only works because crates/cove-runtime/src/vm/mod.rs carries no
module-wide #[allow(dead_code)] — it did once, and while it did this
check passed silently for every candidate, moved or not, which is how
Int.min and Int.max in PR #259
went unverified. Issue #274
narrowed that allow to the individual items that need it, each with its
own comment saying why it has no caller outside its own tests; deleting a
dispatch arm anywhere else in vm::builtins now reaches exactly one of
two outcomes — a clippy failure, or a genuinely shared implementation —
and never the third, silent one this note used to have to warn about.