Cargo projects
Put .rk files where Cargo expects .rs files. These commands transpile every .rk file
under src, examples, tests, and benches, plus build.rk, to a .rs file beside it,
then run the same Cargo command:
renk build
renk check
renk run
renk test
renk clippy
renk doc
renk bench
renk cargo ARGS... # any other cargo command, as cargo ARGS...
A generated file starts with // @generated by renk; do not edit. and is rewritten only when
its content changes. renk stops with an error instead of overwriting a .rs file without that
header.
src/main.rk:
fn main():
println!("{double(21)}")
fn double(n: i32) -> i32 = n * 2
#[cfg(test)]
mod tests:
#[test]
fn doubles():
assert_eq!(super.double(2), 4)
renk run prints 42, and renk test runs doubles. mod name without a body declares a
module file, as mod name; does in Rust.
Diagnostics
- Compiler diagnostics about generated files point at the
.rkline and column and quote the.rksource. Diagnostics about other files print as rustc renders them. - rustc’s suggested replacements are Rust code, so they are left out of
.rkspans. --message-format=shortprintssrc/main.rk:LINE:COLUMN: error: ...lines.--message-format=json...prints cargo’s JSON messages with spans, quoted lines, andrenderedtext moved to the.rkfile.- Panic messages and backtraces from
renk run,renk test, andrenk benchshow.rklocations. A program whose output is a terminal still writes to a terminal. - A name that does not resolve at
a.bgets a help line saying how renk read the dot. See Limits.