R/s3-NULL.R

Defines functions .cstr_construct.NULL.NULL is_corrupted_NULL .cstr_construct.NULL opts_NULL

Documented in opts_NULL

#' @export
#' @rdname other-opts
opts_NULL <- function(
    constructor = "NULL",
    ...) {
  .cstr_options(
    "NULL",
    constructor = constructor,
    ...
  )
}

#' @export
#' @method .cstr_construct NULL
.cstr_construct.NULL <- function(x, ...) {
  opts <- list(...)$opts$`NULL` %||% opts_NULL()
  if (is_corrupted_NULL(x) || opts$constructor == "next") return(NextMethod())
  UseMethod(".cstr_construct.NULL", structure(NA, class = opts$constructor))
}

is_corrupted_NULL <- function(x) {
  typeof(x) != "NULL"
}

#' @export
#' @method .cstr_construct.NULL NULL
.cstr_construct.NULL.NULL <- function(x, ...) {
  "NULL"
}

Try the constructive package in your browser

Any scripts or data that you put into this service are public.

constructive documentation built on April 3, 2025, 9:39 p.m.