[−][src]Crate artichoke
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 Ruby 2.6.3.
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.convert_mut("💎"); let codepoint = s.funcall(&mut interp, "ord", &[] /* args */, None /* block */)?; let codepoint = codepoint.try_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
backtrace | Format Ruby |
parser | Detect if Ruby code parses successfully. |
prelude | A "prelude" for users of the |
repl | A REPL (read–eval–print–loop) for an Artichoke interpreter. |
ruby | Artichoke CLI entrypoint. |
Structs
Artichoke | Interpreter instance. |
Error |
Functions
interpreter | Create a new Artichoke Ruby interpreter. |