Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow explicit name generation #18

Open
kstrafe opened this issue Dec 16, 2018 · 1 comment
Open

Allow explicit name generation #18

kstrafe opened this issue Dec 16, 2018 · 1 comment

Comments

@kstrafe
Copy link

kstrafe commented Dec 16, 2018

Implicit name generation is something that is very dangerous, and we should almost always use hygienic, correctly scoped macros. So instead of making CheeseVec for the following:

#[derive(StructOfArray)]
struct Cheese {
   ...
}

I instead want to specify the resulting SOA name explicitly:

#[derive(StructOfArray(CheeseVec))]
struct Cheese {
   ...
}
@Luthaf
Copy link
Member

Luthaf commented Dec 16, 2018

So I agree that having an option to specify the generated structs names would be nice. I don't have a lot of time, but I would welcome a PR implementing it.

Syntax wise, I don't think it is possible to use a proc-macro like this

#[derive(StructOfArray(CheeseVec))]
struct Cheese {
   ...
}

Instead we would need to do

#[derive(StructOfArray)]
#[soa_derive(vec_name = "CheeseVec")]
struct Cheese {
   ...
}

However, as of today, the proc macro generate 7 structs from Cheese: CheeseVec, CheeseRef, CheeseMut, CheeseSlice, CheeseSliceMut, CheesePtr and CheesePtrMut. So either the could would need all of them to be configurable, or have some kind of prefix to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants