DelSkayn / rquickjs

High level bindings to the quickjs javascript engine
MIT License
435 stars 59 forks source link

#[rquickjs::methods] attribute creates conflicts if multiple impl's have same function name #194

Closed richarddd closed 9 months ago

richarddd commented 11 months ago

If i have one rust module with two structs that have the methods attribute the proc macro will create name conflicts:

example.rs

#[rquickjs::class]
#[derive(rquickjs::class::Trace)]
pub struct A;

#[rquickjs::methods]
impl A {
   fn new() -> Self {
     Self
   }
}

#[rquickjs::class]
#[derive(rquickjs::class::Trace)]
pub struct B;

#[rquickjs::methods]
impl B {
   fn new() -> Self {
     Self
   }
}

conflicting implementation forexample::__impl_new``

To solve this, the generated __impl_ could contain the struct name as well.

I can work around this by using a different file for each struct or different names for the functions, but it would be nice if this was supported 🥇

DelSkayn commented 9 months ago

This is already fixed, the hidden module now contains the class name.