pub unsafe fn setup() -> Cleanup
Available on crate feature
embed
only.Expand description
Performs basic initialisation of the Ruby VM.
This only initialises the core of Ruby’s functionality, some features may
be missing or not work as expected. Generally init
should be preferred,
but there may be some cases where it is not possible to run the full Ruby
initialisation sequence.
Calling this function is only required when embedding Ruby in Rust. It is not required when embedding Rust in Ruby, e.g. in a Ruby Gem.
§Safety
Must be called in main()
, or at least a function higher up the stack than
any code calling Ruby. Must not drop Cleanup until the very end of the
process, after all Ruby execution has finished. Do not use Ruby values
after Cleanup has been dropped.
§Panics
Panics if this, init
, or Ruby::init
are collectively called more
than once.
§Examples
let ruby = unsafe { magnus::embed::setup() };
let result: i64 = ruby.eval("2 + 2").unwrap();
assert_eq!(result, 4);