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],
) -> 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 invisible(x) for pipe-friendly chaining.

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