Skip to content

Xion/runrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runrs

Run Rust modules like scripts

What?

runrs lets you execute Rust source files (*.rs) as if they were compiled binaries or scripts.

$ cat >hello.rs
fn main() {
    println!("Hello, world!");
}
^D
$ runrs ./hello.rs
Hello, world!

It can execute any self-contained Rust program, as long as it's a single file with a main function.

External crates are supported, too! Just make sure the extern crate declarations are in their usual place.

How?

runrs creates an ad-hoc binary crate (cargo new --bin) for each new script it runs.

All those crates live within a single Cargo workspace. This allows them to share their dependencies, avoiding repeated recompilation of common library crates.

Why?

  • For easier scripting with Rust.
  • Because Haskell has runghc and Rust shouldn't be worse.
  • Why not?

Where to?

This is of course an early prototype and there is clearly a room for improvement:

  • handle shebangs correctly
  • handle weird crate name abnormalities (like dash vs. underscore, or stuff like extern crate crypto; translating to rust-crypto crate)
  • better interface (e.g. accept Rust code given via stdin)
  • tests!

About

Runner for Rust scripts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages