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

Only attach required generics to Actor #16

Open
insanitybit opened this issue Jun 12, 2020 · 0 comments
Open

Only attach required generics to Actor #16

insanitybit opened this issue Jun 12, 2020 · 0 comments

Comments

@insanitybit
Copy link
Owner

insanitybit commented Jun 12, 2020

Currently the Actor struct generated will use all method generics and all struct generics.

In reality a struct generic that is not ever used in any methods will never show up in the message type, and therefor can be omitted from the actor.

We should remove these from the actor.

As an example

struct KeyStore<StructOnly, InMethod> {
     struct_only: StructOnly,
     in_method_too: Vec<InMethod>
}

#[derive_actor]
impl<StructOnly, InMethod> KeyStore<StructOnly, InMethod> {
    pub fn store_it(&mut self, thing: InMethod) { self.in_method_too.push(thing); }
}

This would generate an actor of KeyStoreActor<StructOnly, InMethod>, even though StructOnly is never passed through a message. This makes type inference painful - it breaks, and you then need a "phantom method" attached to your impl, and it also makes actors more painful to use.

Instead we should determine which generics actually get used in the actor's methods, and only lift those to the Actor.

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

No branches or pull requests

1 participant