From 737af7da6e9d51c37d2409f6c59650bd1822f4a9 Mon Sep 17 00:00:00 2001 From: Mossa Date: Mon, 13 May 2024 16:04:23 +0200 Subject: [PATCH] removed `use_try_from`, and added `use_rng` --- R/function_options.R | 2 +- README.Rmd | 1 - README.md | 1 - tests/data/ndarray_example.rs | 2 +- tests/testthat/test-extendr_function_options.R | 7 +++---- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/R/function_options.R b/R/function_options.R index 83fd444d..c5d7c0c1 100644 --- a/R/function_options.R +++ b/R/function_options.R @@ -1,9 +1,9 @@ extendr_function_config <- rlang::env( known_options = tibble::tribble( ~Name, ~Ptype, - "use_try_from", logical(), "r_name", character(), "mod_name", character(), + "use_rng", logical() ) ) diff --git a/README.Rmd b/README.Rmd index 95a3d9cb..56be3c57 100644 --- a/README.Rmd +++ b/README.Rmd @@ -125,7 +125,6 @@ rust_function( }", use_dev_extendr = TRUE, # Use development version of extendr from GitHub features = "either", # Enable support for Either crate - extendr_fn_options = list(use_try_from = TRUE) # Enable advanced type conversion ) x <- 1:5 diff --git a/README.md b/README.md index 85e16249..1168815b 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,6 @@ rust_function( }", use_dev_extendr = TRUE, # Use development version of extendr from GitHub features = "either", # Enable support for Either crate - extendr_fn_options = list(use_try_from = TRUE) # Enable advanced type conversion ) x <- 1:5 diff --git a/tests/data/ndarray_example.rs b/tests/data/ndarray_example.rs index 64f68dce..6fe82a71 100644 --- a/tests/data/ndarray_example.rs +++ b/tests/data/ndarray_example.rs @@ -1,6 +1,6 @@ use extendr_api::prelude::*; -#[extendr(use_try_from = true)] +#[extendr] fn matrix_sum(input : ArrayView2) -> Rfloat { input.iter().sum() } diff --git a/tests/testthat/test-extendr_function_options.R b/tests/testthat/test-extendr_function_options.R index 09161830..50d95531 100644 --- a/tests/testthat/test-extendr_function_options.R +++ b/tests/testthat/test-extendr_function_options.R @@ -1,4 +1,4 @@ -test_that("`extendr` code is compiled with `either` feature and `use_try_from` enabled", { +test_that("`extendr` code is compiled with `either` feature", { skip_if_cargo_unavailable() rust_function( @@ -8,7 +8,6 @@ test_that("`extendr` code is compiled with `either` feature and `use_try_from` e Either::Right(right) => Either::Right(right.iter().sum()) } }", - extendr_fn_options = list("use_try_from" = TRUE), features = "either", ) @@ -35,7 +34,7 @@ test_that("`r_name` option renames R function", { }) test_that("`rust_source()` errors if `extendr_fn_options` contains `NULL` value", { - expect_rextendr_error(rust_function("fn func() {}", extendr_fn_options = list("use_try_from" = NULL))) + expect_rextendr_error(rust_function("fn func() {}", extendr_fn_options = list("use_rng" = NULL))) }) test_that("`rust_source()` errors if `extendr_fn_options` contains value of the wrong type", { @@ -43,7 +42,7 @@ test_that("`rust_source()` errors if `extendr_fn_options` contains value of the # due to the use of purrr here, the error that is emitted is on of class `mutate_error` # we cannot expect `rextendr_error` from this function. - expect_error(rust_function("fn func() {}", extendr_fn_options = list("use_try_from" = 42L))) + expect_error(rust_function("fn func() {}", extendr_fn_options = list("use_rng" = 42L))) }) test_that("`rust_source()` errors if `extendr_fn_options` contains option with an invalid name", {