Closed kingsleyh closed 3 months ago
How do I pass a ruby array to a rust function
Utils.run('string1', 'string2', ['apple','pear'])
pub fn run(ruby: &Ruby, param1: String, param2: String, param3: RArray) -> magnus::error::Result<()> { let list = param3.to_vec().iter().map(|v| v.to_string()).collect(); } #[magnus::init] fn init() -> Result<(), magnus::Error> { let module = define_module("Utils")?; module.define_singleton_method("run", function!(run, 3))?; Ok(()) }
This doesn't work - but I don't get any error - it' just fails with unknown error when trying to write an Rspec test
Is what I'm trying to do supported in Magnus? or I need to pass named arguments into the ruby and handle them as an object in rust?
e.g. Utils.run(string1:, string2:, list: ) and in rust pub fn run(ruby:&Ruby, ???? some way to handle the named parameters)
Utils.run(string1:, string2:, list: )
pub fn run(ruby:&Ruby, ???? some way to handle the named parameters)
nevermind - there was something wrong with my environment and nothing was working - but after deleting and re-cloning the repo things started working as expected - weird!
How do I pass a ruby array to a rust function
This doesn't work - but I don't get any error - it' just fails with unknown error when trying to write an Rspec test
Is what I'm trying to do supported in Magnus? or I need to pass named arguments into the ruby and handle them as an object in rust?
e.g.
Utils.run(string1:, string2:, list: )
and in rustpub fn run(ruby:&Ruby, ???? some way to handle the named parameters)