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

Expanding on Root and a potential common-case #703

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bitemyapp
Copy link

Extracted from a real problem I had. I believe this is the only runtime error I encountered. Please let me know what you think.

/// Be careful that you aren't short-circuiting with an early return before
/// your Root value gets into_inner'd or dropped. The following will cause
/// a runtime panic when your error case gets triggered:
/// ```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing doc tests for me locally. I'm not sure why it's not failing in CI. 😕

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have fixed this, I wasn't even thinking about doc tests when I wrote the code.

Copy link
Member

@kjvalencik kjvalencik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I have a few suggestions on wording. Cheers!

@@ -43,6 +43,21 @@ impl<T: Object> Root<T> {
/// The caller _must_ ensure `Root::into_inner` or `Root::drop` is called
/// to properly dispose of the `Root<T>`. If the value is dropped without
/// calling one of these methods, it will *panic*.
///
/// Be careful that you aren't short-circuiting with an early return before
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this communicates the same as above, can it be reworded to present it as an example?

For example, early return with a ? may cause a function to return before freeing a Root. ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've attempted a rewording along the lines suggested here.

///
/// Be careful that you aren't short-circuiting with an early return before
/// your Root value gets into_inner'd or dropped. The following will cause
/// a runtime panic when your error case gets triggered:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer strictly accurate after merging #700

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to delineate panic prior to 0.8, slow path otherwise.

@bitemyapp
Copy link
Author

I merged the doc update with what I did here.

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

Successfully merging this pull request may close these issues.

None yet

2 participants