File: hello_world.rs

package info (click to toggle)
rust-magnus 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,468 kB
  • sloc: ruby: 150; sh: 17; makefile: 2
file content (15 lines) | stat: -rw-r--r-- 324 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
fn hello(subject: String) -> String {
    format!("hello, {}", subject)
}

fn main() {
    magnus::Ruby::init(|ruby| {
        ruby.define_global_function("hello", magnus::function!(hello, 1));

        ruby.eval::<magnus::value::Qnil>(r#"puts hello("world")"#)
            .unwrap();

        Ok(())
    })
    .unwrap()
}