Module: RustExample

Defined in:
lib/rust_example/version.rb,
ext/rust_example/rust_example.c

Overview

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.helloObject



8
9
10
11
12
13
# File 'ext/rust_example/rust_example.c', line 8

VALUE hello(void) {
    char *hello = hello_rust();
    printf("%s\n", hello);

    return Qnil;
}

.make_helloObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'ext/rust_example/rust_example.c', line 15

VALUE make_hello() {
    // "Hello, world!".length == 14, with the null
    char *hello = (char *)malloc(sizeof(char) * 14);

    fill_slice(hello);

    printf("%s\n", hello);

    free(hello);

    return Qnil;
}

.numberObject



28
29
30
31
32
# File 'ext/rust_example/rust_example.c', line 28

VALUE number() {
    int x = num();

    return INT2FIX(x);
}