Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export(use_extendr)
export(use_msrv)
export(vendor_pkgs)
export(write_license_note)
importFrom(dplyr,"%>%")
importFrom(dplyr,mutate)
importFrom(glue,glue)
importFrom(glue,glue_collapse)
Expand Down
2 changes: 1 addition & 1 deletion R/eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn {fn_name}() -> Result<Robj> {{
#' `NULL` if no such dll is loaded.
#' @noRd
find_loaded_dll <- function(name) {
dlls <- keep(getLoadedDLLs(), ~ .x[["name"]] == name)
dlls <- keep(getLoadedDLLs(), \(.x) .x[["name"]] == name)
if (rlang::is_empty(dlls)) {
NULL
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/features.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ validate_extendr_features <- function(features, suppress_warnings) {

features <- unique(features)

unknown_features <- features %>%
setdiff(features_config$known_features) %>%
unknown_features <- features |>
setdiff(features_config$known_features) |>
discard_empty()

if (!isTRUE(suppress_warnings) && length(unknown_features) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion R/rextendr.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @keywords internal
"_PACKAGE"

#' @importFrom dplyr mutate %>%
#' @importFrom dplyr mutate
#' @importFrom glue glue glue_collapse
#' @importFrom rlang dots_list names2 as_function is_missing is_atomic is_null
#' @importFrom rlang is_na .data .env caller_env as_name as_label enquo %||%
Expand Down
16 changes: 8 additions & 8 deletions R/rust_sitrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,32 +120,32 @@ rustup_toolchain_target <- function() {
host_index <- grep("host:", output)
gsub("host: ", "", output[host_index])
} else {
try_exec_cmd("rustup", "show") %>%
stringi::stri_sub(from = 15L) %>%
try_exec_cmd("rustup", "show") |>
stringi::stri_sub(from = 15L) |>
vctrs::vec_slice(1L)
}

# > rustup toolchain list
# stable-x86_64-pc-windows-msvc
# nightly-x86_64-pc-windows-msvc (default)
toolchain_info <- try_exec_cmd("rustup", c("toolchain", "list")) %>%
stringi::stri_trim_both() %>%
toolchain_info <- try_exec_cmd("rustup", c("toolchain", "list")) |>
stringi::stri_trim_both() |>
verify_toolchains(host)

if (is.null(toolchain_info[["missing_toolchain"]]) && is.null(toolchain_info[["candidate_toolchains"]])) {
# > rustup target list --installed
# i686-pc-windows-gnu
# x86_64-pc-windows-gnu
# x86_64-pc-windows-msvc
targets_info <- try_exec_cmd("rustup", c("target", "list", "--installed")) %>%
stringi::stri_trim_both() %>%
targets_info <- try_exec_cmd("rustup", c("target", "list", "--installed")) |>
stringi::stri_trim_both() |>
verify_targets(host)
} else {
targets_info <- list()
}

list(host = host) %>%
append(targets_info) %>%
list(host = host) |>
append(targets_info) |>
append(toolchain_info)
}

Expand Down
18 changes: 9 additions & 9 deletions R/source.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ rust_function <- function(code,
if (vctrs::vec_is_empty(options)) {
attr_arg <- ""
} else {
attr_arg <- options %>%
glue::glue_data("{Name} = {RustValue}") %>%
attr_arg <- options |>
glue::glue_data("{Name} = {RustValue}") |>
glue::glue_collapse(sep = ", ")
attr_arg <- glue::glue("({attr_arg})")
}
Expand Down Expand Up @@ -405,11 +405,11 @@ invoke_cargo <- function(toolchain, specific_target, dir, profile,
#' @noRd
gather_cargo_output <- function(json_output, level, tty_has_colors) {
rendered_output <-
json_output %>%
json_output |>
keep(
~ .x$reason == "compiler-message" && .x$message$level == level
) %>%
map_chr(~ .x$message$rendered)
\(.x) .x$reason == "compiler-message" && .x$message$level == level
) |>
map_chr(\(.x) .x$message$rendered)

if (!tty_has_colors) {
rendered_output <- cli::ansi_strip(rendered_output)
Expand Down Expand Up @@ -446,13 +446,13 @@ check_cargo_output <- function(compilation_result, message_buffer, tty_has_color
cargo_output,
"error",
tty_has_colors
) %>%
) |>
map_chr(
cli::format_inline,
keep_whitespace = TRUE
) %>%
) |>
# removing double new lines with single new line
stringi::stri_replace_all_fixed("\n\n", "\n") %>%
stringi::stri_replace_all_fixed("\n\n", "\n") |>
# ensures that the leading cli style `x` is there
rlang::set_names("x")

Expand Down
22 changes: 11 additions & 11 deletions R/toml_serialization.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ to_toml <- function(...,
names <- names2(args)

# We disallow unnamed top-level atomic arguments
invalid <- which(map2_lgl(names, args, ~ !nzchar(.x) && is.atomic(.y)))
invalid <- which(map2_lgl(names, args, \(.x, .y) !nzchar(.x) && is.atomic(.y)))

# If such args found, display an error message
if (length(invalid) > 0) {
Expand Down Expand Up @@ -97,13 +97,13 @@ get_toml_missing_msg <- function() {
simplify_row <- function(row) {
result <- map_if(
row,
~ is.list(.x) && all(!nzchar(names2(.x))),
~ .x[1],
.else = ~.x
\(.x) is.list(.x) && all(!nzchar(names2(.x))),
\(.x) .x[1],
.else = identity
)
discard(
result,
~ is_na(.x) || is_null(unlist(.x))
\(.x) is_na(.x) || is_null(unlist(.x))
)
}

Expand Down Expand Up @@ -203,7 +203,7 @@ format_toml_atomic <- function(x,
"[ ]"
} else {
formatter <- rlang::as_function(.formatter)
items <- glue_collapse(formatter(x, ...), ", ")
items <- glue_collapse(formatter(x), ", ")
if (len > 1L || !is.null(dims)) {
items <- glue("[ {items} ]")
}
Expand All @@ -223,9 +223,9 @@ format_toml.character <- function(x,
.str_as_literal = TRUE,
.top_level = FALSE) {
if (isTRUE(.str_as_literal)) {
.formatter <- ~ glue("'{.x}'")
.formatter <- \(.x) glue("'{.x}'")
} else {
.formatter <- ~ glue("\"{escape_dbl_quotes(.x)}\"")
.formatter <- \(.x) glue("\"{escape_dbl_quotes(.x)}\"")
}
format_toml_atomic(
x,
Expand All @@ -246,7 +246,7 @@ format_toml.integer <- function(x,
...,
.format_int = .format_int,
.top_level = FALSE,
.formatter = ~ sprintf(.format_int, .x)
.formatter = \(.x) sprintf(.format_int, .x)
)
}

Expand All @@ -260,7 +260,7 @@ format_toml.double <- function(x,
...,
.format_dbl = .format_dbl,
.top_level = FALSE,
.formatter = ~ sprintf(.format_dbl, .x)
.formatter = \(.x) sprintf(.format_dbl, .x)
)
}

Expand All @@ -272,7 +272,7 @@ format_toml.logical <- function(x,
x,
...,
.top_level = FALSE,
.formatter = ~ ifelse(.x, "true", "false")
.formatter = \(.x) ifelse(.x, "true", "false")
)
}

Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ test_that("multiple `rust_eval_deferred()` work correctly", {
provided_values <- seq_len(5)
deferred_handles <- map(
provided_values,
~ rust_eval_deferred(glue::glue("{.x}i32"))
\(.x) rust_eval_deferred(glue::glue("{.x}i32"))
)

obtained_values <- map_int(deferred_handles, ~ (.x)())
obtained_values <- map_int(deferred_handles, rlang::exec)

testthat::expect_equal(
obtained_values,
Expand All @@ -50,12 +50,12 @@ test_that("multiple `rust_eval_deferred()` work correctly in reverse order", {

deferred_handles <- map(
provided_values,
~ rust_eval_deferred(glue::glue("{.x}i32"))
\(.x) rust_eval_deferred(glue::glue("{.x}i32"))
)

deferred_handles <- rev(deferred_handles)

obtained_values <- map_int(deferred_handles, ~ (.x)())
obtained_values <- map_int(deferred_handles, rlang::exec)

testthat::expect_equal(
obtained_values,
Expand Down Expand Up @@ -99,13 +99,13 @@ test_that("`rust_eval_deferred()` environment cleanup", {
dll_path <- attr(handle, "dll_path")

testthat::expect_true(exists(fn_name))
dlls <- keep(getLoadedDLLs(), ~ .x[["path"]] == dll_path)
dlls <- keep(getLoadedDLLs(), \(.x) .x[["path"]] == dll_path)
testthat::expect_length(dlls, 1L)

testthat::expect_equal(handle(), 42L)

testthat::expect_false(exists(fn_name))
dlls <- keep(getLoadedDLLs(), ~ .x[["path"]] == dll_path)
dlls <- keep(getLoadedDLLs(), \(.x) .x[["path"]] == dll_path)
testthat::expect_length(dlls, 0L)
})

Expand Down
Loading