From 497af878c4072588cf8d6b664e045fa324de868a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 15 Jan 2024 13:34:43 +0100 Subject: [PATCH 1/2] refactor: use %||% from rlang --- NAMESPACE | 1 + R/igraph-package.R | 1 + R/utils.R | 13 ------------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 5437124cb0..9d639817f9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -914,6 +914,7 @@ importFrom(pkgconfig,set_config) importFrom(pkgconfig,set_config_in) importFrom(rlang,.data) importFrom(rlang,.env) +importFrom(rlang,`%||%`) importFrom(rlang,check_dots_empty) importFrom(rlang,check_installed) importFrom(rlang,inject) diff --git a/R/igraph-package.R b/R/igraph-package.R index 2a948e1dec..f4a61efab9 100644 --- a/R/igraph-package.R +++ b/R/igraph-package.R @@ -9,6 +9,7 @@ #' @importFrom rlang check_installed #' @importFrom rlang inject #' @importFrom rlang warn +#' @importFrom rlang `%||%` ## usethis namespace: end NULL diff --git a/R/utils.R b/R/utils.R index 70729f7ae3..a5469af9a8 100644 --- a/R/utils.R +++ b/R/utils.R @@ -41,19 +41,6 @@ add_class <- function(x, class) { x } -`%||%` <- function(lhs, rhs) { - lres <- withVisible(eval(lhs, envir = parent.frame())) - if (is.null(lres$value)) { - eval(rhs, envir = parent.frame()) - } else { - if (lres$visible) { - lres$value - } else { - invisible(lres$value) - } - } -} - `%&&%` <- function(lhs, rhs) { lres <- withVisible(eval(lhs, envir = parent.frame())) if (!is.null(lres$value)) { From 4e04d267edf33ef57438cad1d085d7069857c8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 15 Jan 2024 13:46:00 +0100 Subject: [PATCH 2/2] oops --- NAMESPACE | 2 +- R/igraph-package.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9d639817f9..e1c4ab5393 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -912,9 +912,9 @@ importFrom(magrittr,"%>%") importFrom(pkgconfig,get_config) importFrom(pkgconfig,set_config) importFrom(pkgconfig,set_config_in) +importFrom(rlang,"%||%") importFrom(rlang,.data) importFrom(rlang,.env) -importFrom(rlang,`%||%`) importFrom(rlang,check_dots_empty) importFrom(rlang,check_installed) importFrom(rlang,inject) diff --git a/R/igraph-package.R b/R/igraph-package.R index f4a61efab9..07e28f7531 100644 --- a/R/igraph-package.R +++ b/R/igraph-package.R @@ -9,7 +9,7 @@ #' @importFrom rlang check_installed #' @importFrom rlang inject #' @importFrom rlang warn -#' @importFrom rlang `%||%` +#' @importFrom rlang %||% ## usethis namespace: end NULL