miniextendr_macros/vctrs_generics.rs
1//! Known vctrs S3 generic names used to auto-insert `@importFrom vctrs`.
2//!
3//! Independent of the `vctrs` feature flag — users can write
4//! `#[miniextendr(s3(generic = "vec_proxy", class = "my_class"))]` whether or
5//! not the `Vctrs` derive is enabled.
6
7/// All vctrs-exported generics users might implement S3 methods for.
8const VCTRS_GENERICS: &[&str] = &[
9 // Core proxy/restore (required for most custom types)
10 "vec_proxy",
11 "vec_restore",
12 // Type coercion (required for vec_c, vec_rbind, etc.)
13 "vec_ptype2",
14 "vec_cast",
15 // Equality/comparison/ordering proxies
16 "vec_proxy_equal",
17 "vec_proxy_compare",
18 "vec_proxy_order",
19 // Printing/formatting
20 "vec_ptype_abbr",
21 "vec_ptype_full",
22 "obj_print_data",
23 "obj_print_footer",
24 "obj_print_header",
25 // str() output
26 "obj_str_data",
27 "obj_str_footer",
28 "obj_str_header",
29 // Arithmetic (for numeric-like types)
30 "vec_arith",
31 "vec_math",
32 // Other
33 "vec_ptype_finalise",
34 "vec_cbind_frame_ptype",
35 // List-of conversion
36 "as_list_of",
37];
38
39/// Returns `true` if `generic` is a vctrs generic that needs `@importFrom vctrs`.
40#[inline]
41pub(crate) fn is_vctrs_generic(generic: &str) -> bool {
42 VCTRS_GENERICS.contains(&generic)
43}