extendr
extendr copied to clipboard
Consider panic if not type function or macro
I am finding myself doing type checking inside of rust functions that accept a vctrs_vctr
which is a list of pointers to struct impl
s. I cannot create a vector of pointers without the List Altrep https://github.com/extendr/extendr/issues/503 so the type checking from rust only checks for List
.
To check that the vector class is correct i write something along the lines of
fn check_class(x: List) {
if !x.inherits("my_vctrs_vctr") {
panic!("`x` must be of class `"my_vctrs_vctr"`)
}
}
A helper function / macro would be very useful here.