[rubygems/rubygems] update Magnus library in Rust extension gem template
https://github.com/rubygems/rubygems/commit/19a92a3367
This commit is contained in:
parent
36023d5cb7
commit
a3c0e9d90d
@ -12,4 +12,4 @@ publish = false
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
magnus = { version = "0.4" }
|
magnus = { version = "0.6" }
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use magnus::{define_module, function, prelude::*, Error};
|
use magnus::{function, prelude::*, Error, Ruby};
|
||||||
|
|
||||||
fn hello(subject: String) -> String {
|
fn hello(subject: String) -> String {
|
||||||
format!("Hello from Rust, {}!", subject)
|
format!("Hello from Rust, {subject}!")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[magnus::init]
|
#[magnus::init]
|
||||||
fn init() -> Result<(), Error> {
|
fn init(ruby: &Ruby) -> Result<(), Error> {
|
||||||
let module = <%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
|
let module = ruby.<%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
|
||||||
module.define_singleton_method("hello", function!(hello, 1))?;
|
module.define_singleton_method("hello", function!(hello, 1))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user