Skip to content

Commit

Permalink
Use length() for simplicity and clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Nov 29, 2022
1 parent 44abd0a commit d9287d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ rename_with.data.frame <- function(.data, .fn, .cols = everything(), ...) {
"{.arg .fn} must return a character vector, not {.obj_type_friendly {new}}."
)
}
if (vec_size(new) != vec_size(sel)) {
if (length(new) != length(sel)) {
cli::cli_abort(
"{.arg .fn} must return a vector of size {vec_size(sel)}, not {vec_size(new)}."
"{.arg .fn} must return a vector of length {length(sel)}, not {length(new)}."
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
rename_with(df, fn)
Condition
Error in `rename_with()`:
! `.fn` must return a vector of size 2, not 3.
! `.fn` must return a vector of length 2, not 3.

# can't rename in `.cols`

Expand Down

0 comments on commit d9287d1

Please sign in to comment.