pub struct Binding(pub Value);Expand description
A binding is basically an execution context. Variables and classes defined inside a binding are only accessible within that binding.
Tuple Fields§
§0: ValueImplementations§
Source§impl Binding
impl Binding
Sourcepub fn top_level() -> Self
pub fn top_level() -> Self
The top level binding (the global context) accessible in Ruby via TOPLEVEL_BINDING
constant. This binding is a superset of all other bindings. Executions on it act
as if they were executed in all possible bindings.
Examples found in repository?
examples/repl.rs (line 16)
3fn main() {
4 unsafe { mri_sys::ruby_init() };
5
6 loop {
7 print!("cool-interpreter:8=====D -- ");
8 std::io::stdout().flush().unwrap();
9
10 let mut input = String::new();
11 std::io::stdin().read_line(&mut input).expect("could not read from stdin");
12
13 match &input.trim().to_lowercase()[..] {
14 "exit" | "quit" => break,
15 "help" => println!("-> https://www.eapservices.co.nz/"),
16 _ => match mri_sys::helpers::eval(&input, mri_sys::helpers::Binding::top_level(), Some("mock-filename.rb")) {
17 Ok(value) => println!("-> {:?}", value),
18 Err(e) => eprintln!("ERROR, EXCEPTION RAISED: {}", e),
19 },
20 }
21 }
22
23 unsafe { mri_sys::ruby_cleanup(0) };
24}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Binding
impl RefUnwindSafe for Binding
impl Send for Binding
impl Sync for Binding
impl Unpin for Binding
impl UnsafeUnpin for Binding
impl UnwindSafe for Binding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more