Skip to main content

run_with_cargo

Function run_with_cargo 

Source
pub fn run_with_cargo(
    source: &str,
    source_path: Option<&Path>,
    extra_args: &[String],
) -> Result<(), String>
Expand description

Compiles and runs a Rust source file that has embedded dependencies.

  1. Parses the //! manifest from the source
  2. Creates a cached Cargo project directory
  3. Writes Cargo.toml and src/main.rs
  4. Invokes cargo run --quiet

Stdin/stdout/stderr are inherited, so the program interacts with the terminal normally.