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

Implement From<> trait for actor message enum #161

Open
elenaf9 opened this issue Feb 1, 2021 · 0 comments
Open

Implement From<> trait for actor message enum #161

elenaf9 opened this issue Feb 1, 2021 · 0 comments

Comments

@elenaf9
Copy link
Contributor

elenaf9 commented Feb 1, 2021

The actor macro currently implements Into<#name> for #ty for each message type (#ty) in the message enum (#name), which enables converting from a specific message to the expected message enum.
From my point of view, implementing From<#ty> for #name would also implement the Into trait, but additionally serve more use cases, especially when working with generic message types, e.g. in such a case:

struct MyMessage;

struct MyStruct<T>
where
     T: From<MyMessage>
{
    actor: ActorRef<T>
}

impl<T> MyStruct<T> 
where
     T: From<MyMessage>
{
     fn msg_actor(&self, msg: MyMessage) {
           self.actor.tell(msg, None)
    }
}

Was there a specific reason for implementing Into instead of From?

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