Expand description
Artichoke Ruby
This crate is a Rust and Ruby implementation of the Ruby programming language. Artichoke is not production-ready, but intends to be a MRI-compliant implementation of recent MRI Ruby.
This crate provides:
- An embeddable Ruby interpreter, which can be created with the
interpreter
function. - A Rust and Ruby implementation of Ruby Core and Standard Library using high-quality Rust dependencies and modern Ruby.
- Support for injecting Rust code and types into the interpreter with a
rubygems-style
File
API. - The ability to disable parts of the interpreter VM or library functions at
compile time. For example, deny access to the system environ by disabling
the
core-env-system
feature.
§Usage
You can create an interpreter and begin executing code on it:
use artichoke::prelude::*;
let mut interp = artichoke::interpreter()?;
let result = interp.eval(b"2 + 5")?;
Artichoke supports calling Ruby functions from Rust and converting between Ruby boxed values and Rust native types:
use artichoke::prelude::*;
let mut interp = artichoke::interpreter()?;
let s = interp.try_convert_mut("💎")?;
let codepoint = s.funcall(
&mut interp,
"ord",
&[], /* args */
None, /* block */
)?;
let codepoint = codepoint.try_convert_into::<u32>(&interp)?;
assert_eq!(128142, codepoint);
§Crate Features
All features are enabled by default.
The features exposed by this crate are unstable. Please refer to the
documentation in the source Cargo.toml
.
Re-exports§
pub use artichoke_backend as backend;
Modules§
- Format Ruby
Exception
backtraces. - Detect if Ruby code parses successfully.
- A “prelude” for users of the
artichoke
crate. - A REPL (read–eval–print–loop) for an Artichoke interpreter.
- Artichoke CLI entry point.
Structs§
- Interpreter instance.
- The
Error
type, a wrapper around a dynamic exception type.
Functions§
- Create a new Artichoke Ruby interpreter.