Add info about ConnectHandle.#124
Conversation
Bromeon
left a comment
There was a problem hiding this comment.
Great example with invulnerability 👍
src/register/signals.md
Outdated
| impl Monster { | ||
| fn make_invulnerable(&mut self) { | ||
| if let Some(connection) = self.handle.take() | ||
| && connection.is_connected() |
There was a problem hiding this comment.
| && connection.is_connected() | |
| && connection.is_connected() |
(Rustfmt would indent this)
But I would not recommend is_connected() as general practice; it's needed only if there is no clear ownership of the signal, or if the involved object is expected to die. Maybe there could be a comment about a potential panic instead.
d167d67 to
75e418a
Compare
| if let Some(connection) = self.handle.take() | ||
| && connection.is_connected() | ||
| { |
There was a problem hiding this comment.
| if let Some(connection) = self.handle.take() | |
| && connection.is_connected() | |
| { | |
| if let Some(connection) = self.handle.take() | |
| /* && connection.is_connected() -- see above */ | |
| { |
There was a problem hiding this comment.
Or even just
if let Some(connection) = self.handle.take() { There was a problem hiding this comment.
I did it on purpose this time, see comment over this section:
Disconnecting a signal will result in panic if given connection does not exist.
Useis_connected()when there is no clear ownership of the signal or connected object is expected to be freed.
alternatively I can remove the whole 2nd section 🤔.
75e418a to
dc73ba9
Compare
|
Thank you! |
No description provided.