-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I have a case where I know the type I'm casting .to, and that .to also has a known name, so I'd like to also supply .to_arg, like you already can with vec_cast() itself.
I am fairly certain that to make this work we will have to give vec_ptype_common() a .ptype_arg argument as well, because we end up supplying .to as .ptype and we will need to tweak the name used there.
library(vctrs)
x <- 1
# I'd like to be able to use this!
x_arg <- "this"
elements <- list(
1L,
2,
"x"
)
vec_cast_common(
!!!elements,
.to = x,
.arg = "elements"
)
#> Error:
#> ! Can't convert `elements[[3]]` <character> to <double>.
# Like this
vec_cast(
elements[[3]],
to = x,
to_arg = x_arg
)
#> Error:
#> ! Can't convert `elements[[3]]` <character> to match type of `this` <double>.Created on 2025-07-15 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels