-
Notifications
You must be signed in to change notification settings - Fork 62
Add info about ConnectHandle.
#124
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
Add info about ConnectHandle.
#124
Conversation
Bromeon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| && 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even just
if let Some(connection) = self.handle.take() { There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.