📁 File Manager Pro
v10.0.2 | PHP: 8.1.34
Server: LiteSpeed
2026-06-30 02:42:01
📂
/
/
opt
/
alt
/
ruby40
/
share
/
gems
/
gems
/
bundler-4.0.10
/
lib
/
bundler
/
templates
/
newgem
/
ext
/
newgem
/
src
✏️
Editing: lib.rs.tt
use magnus::{function, prelude::*, Error, Ruby}; pub fn hello(subject: String) -> String { format!("Hello {subject}, from Rust!") } #[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(()) } #[cfg(test)] mod tests { use rb_sys_test_helpers::ruby_test; use super::hello; #[ruby_test] fn test_hello() { assert_eq!("Hello world, from Rust!", hello("world".to_string())); } }
💾 Save Changes
❌ Cancel