Skip to main content

generate_trait_s3_r_wrapper

Function generate_trait_s3_r_wrapper 

Source
fn generate_trait_s3_r_wrapper(
    type_ident: &Ident,
    trait_name: &Ident,
    methods: &[TraitMethod],
    consts: &[TraitConst],
    impl_preconditions: Option<bool>,
) -> String
Expand description

Generate S3-style R wrapper code (generic + method.Type).

For impl Counter for SimpleCounter, generates:

  • S3 generic value(x, ...) (if not already defined)
  • S3 method value.SimpleCounter <- function(x, ...) { .Call(...) }
  • S7 method registration if the generic is an S7 generic

Static methods and constants use Type$Trait$name namespace (env-style). Void instance methods return the receiver x for pipe-friendly chaining (invisibly only when marked Invisible<..>, #1213).

Also used for ClassSystem::Vctrs since vctrs uses S3 under the hood.