Skip to main content

embed/
embed.rs

1//! The example in README.md, kept compilable so the two cannot drift.
2use quickjs::{Context, Runtime};
3
4fn main() -> Result<(), quickjs::Error> {
5    let runtime = Runtime::new();
6    let mut context = Context::new(&runtime);
7    context.eval("print([1, 2, 3].map(x => x * 2).join('-'));")?;
8    assert_eq!(context.output(), "2-4-6\n");
9    print!("{}", context.output());
10    Ok(())
11}