Skip to content

Commit 669a0e7

Browse files
committed
Explain condition for copy_names() in str_sub() and str_pad().
1 parent 463bb58 commit 669a0e7

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

R/pad.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ str_pad <- function(
4444
right = stri_pad_right(string, width, pad = pad, use_length = !use_width),
4545
both = stri_pad_both(string, width, pad = pad, use_length = !use_width)
4646
)
47+
# Preserve names unless `string` is recycled
4748
if (length(out) == length(string)) copy_names(string, out) else out
4849
}

R/sub.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ str_sub <- function(string, start = 1L, end = -1L) {
6969
} else {
7070
stri_sub(string, from = start, to = end)
7171
}
72+
# Preserve names unless `string` is recycled
7273
if (length(out) == length(string)) copy_names(string, out) else out
7374
}
7475

0 commit comments

Comments
 (0)