extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
196 stars 28 forks source link

Support #[extendr(...)] #130

Closed yutannihilation closed 3 years ago

yutannihilation commented 3 years ago

Fix #128

devtools::load_all("~/repo/rextendr/")
#> ℹ Loading rextendr

code <- r"(
#[extendr(use_try_from = true)]
fn test_i32(val: i32) -> i32 {
    val
}
)"

rust_source(code = code, patch.crates_io = list(`extendr-api` = list(git = "https://github.com/extendr/extendr")))
#> ℹ build directory: '/tmp/RtmpmY1R1g/file15abe30edf0cc'
#> ✓ Writing '/tmp/RtmpmY1R1g/file15abe30edf0cc/target/extendr_wrappers.R'.

test_i32(1)
#> [1] 1

Created on 2021-07-17 by the reprex package (v2.0.0)