Skip to main content

generate_trait_r6_r_wrapper

Function generate_trait_r6_r_wrapper 

Source
fn generate_trait_r6_r_wrapper(
    type_ident: &Ident,
    trait_name: &Ident,
    methods: &[TraitMethod],
    consts: &[TraitConst],
) -> String
Expand description

Generate R6-style R wrapper code.

R6 classes are defined monolithically (all methods in R6Class()), so trait methods cannot be injected into the class definition. Instead, they are generated as standalone exported functions that accept the R6 object.

For impl Counter for SimpleCounter, generates:

  • r6_trait_Counter_value(x) – exported standalone function
  • r6_trait_Counter_increment(x) – exported standalone function

Instance method names are prefixed with r6_trait_{Trait}_ to avoid collisions. Static methods and constants use Type$Trait$name namespace (env-style).