artichoke_backend/
top_self.rs

1use crate::Artichoke;
2use crate::core::TopSelf;
3use crate::sys;
4use crate::value::Value;
5
6impl TopSelf for Artichoke {
7    type Value = Value;
8
9    fn top_self(&mut self) -> Value {
10        // SAFETY: `mrb_top_self` requires an initialized mruby interpreter
11        // which is guaranteed by the `Artichoke` type.
12        let top_self = unsafe { self.with_ffi_boundary(|mrb| sys::mrb_top_self(mrb)) };
13        top_self.map(Value::from).unwrap_or_default()
14    }
15}