Is there a way to compile rust code from a string? Something like
use rustc::compile;
let code: &str = r#"fn main() { println!("Hello from Rust!"); }"#;
let result = rustc::compile(code).unwrap();
println!("{}", result);
Is there a way to compile rust code from a string? Something like
use rustc::compile;
let code: &str = r#"fn main() { println!("Hello from Rust!"); }"#;
let result = rustc::compile(code).unwrap();
println!("{}", result);
You need to invoke the Rust compiler. Either with a new process or linking with the compiler libraries.
But compiled programs should not compile code unless they have a very good reason.