Skip to main content

generate_trait_env_r_wrapper

Function generate_trait_env_r_wrapper 

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

Generate Env-style R wrapper code for trait methods.

Env-class trait methods use a namespace hierarchy: Type$Trait$method(x, ...). Instance methods take x as the first parameter (the self object) and are stamped with .__mx_instance__ attribute for $ dispatch detection. Void instance methods return invisible(x) for pipe-friendly chaining.

Static methods and constants also live under Type$Trait$name.

Returns an error if an instance method has a parameter named x (collides with the self parameter in env-class dispatch).