Is there a use case (or consequences) for defining the ractor::Actor
struct with state?
#271
-
All the examples define the actor as an empty structure: struct Actor;
impl ractor::Actor for Actor {
...
} Are there consequences to adding immutable state to the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Nope it's fine to do technically and has no impact but it does mean you need to construct that immutable state outside of the actor spawning flow which does introduce a panic risk to the parent actor. Since it won't be managed for you. It's the motivation for why the state is a separate struct, which I think there's a note on the main readme. But for simple things with no risk, it's completely fine as long as you don't need mutability |
Beta Was this translation helpful? Give feedback.
Nope it's fine to do technically and has no impact but it does mean you need to construct that immutable state outside of the actor spawning flow which does introduce a panic risk to the parent actor. Since it won't be managed for you.
It's the motivation for why the state is a separate struct, which I think there's a note on the main readme. But for simple things with no risk, it's completely fine as long as you don't need mutability