jundl77
jundl77

Reputation: 476

How do I interpret or otherwise evaluate Rust at runtime?

I've been searching, and while this seems to be a much-wanted feature, all search results seem to be at least one year old.

What is the current state of this? Is there a good solution to evaluating arbitrary Rust code at runtime (like Haskell's hint)?

Maybe something can be done with Miri?

Upvotes: 3

Views: 2460

Answers (1)

Shepmaster
Shepmaster

Reputation: 431669

Miri (short for MIR Interpreter) is the de-facto interpreter of Rust code. It is what powers the compile-time function evaluation inside of rustc, the Rust compiler, but Miri is more featureful than what is currently used by compiler.

For experimentation purposes, Miri is also available in the Rust playground. It can be used to evaluate a particular run of a program, detecting if certain types of undefined behavior exist.

Miri does not provide a Rust REPL, but it may be part of creating such a tool.

Upvotes: 6

Related Questions