#cargo #script

app rust-script

Command-line tool to run Rust "scripts" which can make use of crates

33 breaking releases

0.34.0 Sep 26, 2023
0.32.0 Sep 26, 2023
0.30.0 Jul 27, 2023
0.23.0 Mar 25, 2023
0.9.0 Nov 4, 2020

#117 in Development tools

Download history 999/week @ 2023-10-31 1186/week @ 2023-11-07 943/week @ 2023-11-14 938/week @ 2023-11-21 1330/week @ 2023-11-28 1114/week @ 2023-12-05 1269/week @ 2023-12-12 2706/week @ 2023-12-19 1299/week @ 2023-12-26 2393/week @ 2024-01-02 3533/week @ 2024-01-09 3494/week @ 2024-01-16 2135/week @ 2024-01-23 4916/week @ 2024-01-30 2597/week @ 2024-02-06 2498/week @ 2024-02-13

12,697 downloads per month

MIT/Apache

82KB
2.5K SLoC

CI Crates.io MSRV

rust-script

Run Rust script files without any setup or explicit compilation step, with seamless use of crates specified as dependencies inside the scripts.

$ cargo install rust-script
[...]

$ cat script.rs
#!/usr/bin/env rust-script
//! Dependencies can be specified in the script file itself as follows:
//!
//! ```cargo
//! [dependencies]
//! rand = "0.8.0"
//! ```

use rand::prelude::*;

fn main() {
    let x: u64 = random();
    println!("A random number: {}", x);
}

$ ./script.rs
A random number: 9240261453149857564

Rust version 1.64 or newer required.

See the documentation at rust-script.org.

  • cargo-script - the unmaintained project that rust-script was forked from.
  • cargo-eval - maintained fork of cargo-script.
  • cargo-play - local Rust playground.
  • runner - tool for running Rust snippets.
  • scriptisto - language-agnostic "shebang interpreter" that enables you to write scripts in compiled languages.

License

rust-script is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Dependencies

~7–19MB
~244K SLoC