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
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.70 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.69 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.68 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.67 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.66 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.65 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.64 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.63 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.62 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.61 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt