Sha256: bf17b928cafb2163850f7571b17460285037cdcdc5318a34753d9fbc0f8a82e6

Contents?: true

Size: 368 Bytes

Versions: 19

Compression:

Stored size: 368 Bytes

Contents

fn fib(n: usize) -> usize {
    match n {
        0 => 0,
        1 | 2 => 1,
        _ => fib(n - 1) + fib(n - 2),
    }
}

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

        ruby.eval::<magnus::Value>("p (0..12).map {|n| fib(n)}")
            .unwrap();

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/magnus-0.7.1/examples/fibonacci.rs
wasmtime-28.0.0 ./ext/cargo-vendor/magnus-0.7.1/examples/fibonacci.rs
wasmtime-27.0.0 ./ext/cargo-vendor/magnus-0.7.1/examples/fibonacci.rs
wasmtime-26.0.0 ./ext/cargo-vendor/magnus-0.7.1/examples/fibonacci.rs
wasmtime-25.0.2 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-25.0.1 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-25.0.0 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-24.0.0 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-23.0.2 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-22.0.0 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-21.0.1 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-20.0.2 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-20.0.0 ./ext/cargo-vendor/magnus-0.6.4/examples/fibonacci.rs
wasmtime-18.0.3 ./ext/cargo-vendor/magnus-0.6.2/examples/fibonacci.rs
wasmtime-17.0.1 ./ext/cargo-vendor/magnus-0.6.2/examples/fibonacci.rs
wasmtime-17.0.0 ./ext/cargo-vendor/magnus-0.6.2/examples/fibonacci.rs
wasmtime-16.0.0 ./ext/cargo-vendor/magnus-0.6.2/examples/fibonacci.rs
wasmtime-15.0.1 ./ext/cargo-vendor/magnus-0.6.2/examples/fibonacci.rs
wasmtime-15.0.0 ./ext/cargo-vendor/magnus-0.6.2/examples/fibonacci.rs