How to read the user input as source code?

I am trying to do this:

  1. Establish a website just like rust playground
  2. Take the user's input, then convert the input to Rust code and put it in a main.rs.
  3. Run the main.rs in my crate as the same as running it in the main.rs from in the source code. And return the outcome to the website.
    How can I do it?

The playground is open source, you can see how it works yourself

The short answer is that you have to call the compiler somehow though. There's no simple standard library API you can call to run Rust source code or anything like that

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.