-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Misc API doc improvements #14304
Misc API doc improvements #14304
Conversation
//! impl Graph { | ||
//! fn minimum_spanning_tree(&self) -> Vec<(uint, uint)> { | ||
//! // Create a new scope to contain the lifetime of the | ||
//! // dynamic borrow |
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.
Do we want to encourage using scopes to contain RefCell
borrows, or is it better to encourage the use of drop()
on the borrowed Ref
? We need scopes for &mut
, but drop()
is sufficient for Ref
.
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 like the visual aspect of the new scope.
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.
Perhaps, but there are definitely cases where drop()
is more useful. The question is, do we want to suggest to readers that the scope is necessary here, like it is with &mut
, or do we want to show them that drop()
works?
I'm ok with either answer, I just want to make sure it's an intentional choice.
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 don't care strongly but I'll rationalize this choice as: blocks are the more fundamental way for handling value lifetimes; they are built into the language, so they are more appropriate for demonstrating basic concepts.
Overall this is pretty good. r=me with comments. |
changelog: none
Includes module docs for
cell
.