Sha256: 8cc6a3ebfde3be23e1bdae650ea9b633a2b9d828e233ecfc8d8062004dba0db6

Contents?: true

Size: 376 Bytes

Versions: 143

Compression:

Stored size: 376 Bytes

Contents

use magnus::{function, prelude::*, Error, Ruby};

fn hello(subject: String) -> String {
    format!("Hello from Rust, {subject}!")
}

#[magnus::init]
fn init(ruby: &Ruby) -> Result<(), Error> {
    let module = ruby.<%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
    module.define_singleton_method("hello", function!(hello, 1))?;
    Ok(())
}

Version data entries

143 entries across 143 versions & 5 rubygems

Version Path
rubygems-update-3.6.3 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.6.3 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.6.2 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.6.2 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.6.1 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.6.1 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.6.0 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.6.0 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.23 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.23 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.22 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.22 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.21 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.21 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.20 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.20 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt