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

Register generic argument use at startup #275

Open
andriyDev opened this issue May 24, 2023 · 0 comments
Open

Register generic argument use at startup #275

andriyDev opened this issue May 24, 2023 · 0 comments

Comments

@andriyDev
Copy link

I don't really know how to go about this, so I've come here (since I figure you all might have more understanding). Essentially what I want is to create a factory of every type that a function is called for (essentially every monomorphization).

The following is roughly my code:

fn do_something_with<T>(t: T) {
  #[ctor::ctor]
  fn register() {
    register_factory::<T>();
  }

  // Do something with t
  ...
}

fn register_factory<T>() {
  // Put T in a HashMap after making a factory type.
  ...
}

Unfortunately, I can't do this because the register function can't refer to T, due to rustc --explain E0401 (inner fns do not inherit type or const parameters from functions they are embedded in).

I'm not sure if this is even possible, or maybe there's a way to extend ctor to allow calling generic functions?

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

1 participant