Sha256: 8cc6a3ebfde3be23e1bdae650ea9b633a2b9d828e233ecfc8d8062004dba0db6

Contents?: true

Size: 376 Bytes

Versions: 134

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

134 entries across 134 versions & 4 rubygems

Version Path
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
rubygems-update-3.5.19 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.19 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.18 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.18 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.17 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.17 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.16 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
bundler-2.5.16 lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
rubygems-update-3.5.15 bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt