30 releases

0.9.1 Aug 9, 2021
0.9.0 Mar 16, 2021
0.8.0 Jan 19, 2021
0.7.0 Oct 19, 2020
0.0.0 Jul 12, 2018

#58 in Development tools

Download history 50/week @ 2021-06-05 17/week @ 2021-06-12 13/week @ 2021-06-19 21/week @ 2021-06-26 15/week @ 2021-07-03 20/week @ 2021-07-10 51/week @ 2021-07-17 41/week @ 2021-07-24 70/week @ 2021-07-31 47/week @ 2021-08-07 51/week @ 2021-08-14 18/week @ 2021-08-21 3/week @ 2021-08-28 4/week @ 2021-09-04 24/week @ 2021-09-11 19/week @ 2021-09-18

130 downloads per month
Used in less than 8 crates

MIT/Apache

1.5MB
41K SLoC

rune

Rune Logo



An embeddable dynamic programming language for Rust.

Contributing

If you want to help out, there should be a number of optimization tasks available in Future Optimizations. Or have a look at Open Issues.

Create an issue about the optimization you want to work on and communicate that you are working on it.


Highlights of Rune


Rune scripts

You can run Rune programs with the bundled CLI:

cargo run --bin rune -- run scripts/hello_world.rn

If you want to see detailed diagnostics of your program while it's running, you can use:

cargo run --bin rune -- run scripts/hello_world.rn --dump-unit --trace --dump-vm

See --help for more information.

Running scripts from Rust

You can find more examples in the examples folder.

The following is a complete example, including rich diagnostics using termcolor. It can be made much simpler if this is not needed.

use rune::termcolor::{ColorChoice, StandardStream};
use rune::EmitDiagnostics as _;
use runestick::{Vm, FromValue as _, Item, Source};

use std::error::Error;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let context = runestick::Context::with_default_modules()?;
    let options = rune::Options::default();

    let mut sources = rune::Sources::new();
    sources.insert(Source::new(
        "script",
        r#"
        pub fn calculate(a, b) {
            println("Hello World");
            a + b
        }
        "#,
    ));

    let mut diagnostics = rune::Diagnostics::new();

    let result = rune::load_sources(&context, &options, &mut sources, &mut diagnostics);

    if !diagnostics.is_empty() {
        let mut writer = StandardStream::stderr(ColorChoice::Always);
        diagnostics.emit_diagnostics(&mut writer, &sources)?;
    }

    let unit = result?;
    let vm = Vm::new(Arc::new(context.runtime()), Arc::new(unit));

    let mut execution = vm.execute(&["calculate"], (10i64, 20i64))?;
    let value = execution.async_complete().await?;

    let value = i64::from_value(value)?;

    println!("{}", value);
    Ok(())
}

Dependencies

~3–4MB
~83K SLoC