Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use #[extendr(...)] in rust_source() #128

Closed
yutannihilation opened this issue Jul 17, 2021 · 1 comment · Fixed by #130
Closed

Cannot use #[extendr(...)] in rust_source() #128

yutannihilation opened this issue Jul 17, 2021 · 1 comment · Fixed by #130

Comments

@yutannihilation
Copy link
Contributor

As extendr/extendr#222 adds an option to #[extendr()] macro, I wonder how the options should be supported on rextendr's side and then wanted to try the code below, but it fails with a cryptic error. I'll take a look later, but please let me know if I'm missing something very obvious...

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

rextendr::rust_source(code = code, patch.crates_io = list(`extendr-api` = list(git = "https://github.com/extendr/extendr")))
#> ℹ build directory: '/tmp/RtmphmzVDp/file14a9598749e1'
#> Error: Problem with `mutate()` input `..1`.
#> ℹ `..1 = .data$name`.
#> x Column `name` not found in `.data`

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

@yutannihilation
Copy link
Contributor Author

We need to update this regex, at least.

# Finds lines which contain #[extendr] (allowing additional spaces)
find_extendr_attrs_ids <- function(lns) {
which(stringi::stri_detect_regex(lns, "#\\s*\\[\\s*extendr\\s*\\]"))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant