-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve Rc documentation #15251
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
Improve Rc documentation #15251
Conversation
@@ -21,6 +21,127 @@ freed. | |||
For example, a tree with parent pointers can be represented by putting the nodes behind `Strong` | |||
pointers, and then storing the parent pointers as `Weak` pointers. | |||
|
|||
|
|||
#Examples |
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.
There should be a space here, and I think we use h2 for this, not h1
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.
@steveklabnik will do on the h2. Not sure where you want the space to be put, though? Do you mean a space character, or vertical space? Thanks :-).
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.
After the #
.
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.
Ah ok, thanks! Latest commit should have fixed it up.
I just gave this a quick look-over, and it seems like a decent example to me. Eventually, we'll have big explanations like this in an ownership guide, but always better to improve things early and often. |
|
||
```rust | ||
use std::rc::Rc; | ||
use std::string::String; |
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.
String
is in the prelude so you shouldn't need to import it.
Looks great to me, thanks! It's ok if it's not an actual url, a reference is good enough (we have search!) With a squash I think bors is ready for this. |
@alexcrichton great! I'm moderately sure that the build error was a problem with the build engine rather than the code changes: make check works flawlessly on my system, and the build engine error was '/home/travis/build.sh: line 226: travis_wait: command not found'. Is there a way to get it to retry the build? |
It's ok to ignore an error like that on travis, it's likely just spurious |
OK great - I've squashed it now. |
I've seen quite a bit of confusion around regarding the use of Rc, so I thought I'd take a stab at adding some examples.
Skip building subtrees for builtin derives This is a waste of resources, we go from node to subtree just to go from subtree to node in the expander impl. We can skip the subtree building and only build the tokenmap instead.
I've seen quite a bit of confusion around regarding the use of Rc, so I thought I'd take a stab at adding some examples.