-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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.
Follow-up of rust-lang/rust-clippy#15208. This PR removes the CSS `bootstrap` dependency which contains 1504 CSS rules and weights 16.1 kB minified. Considering we used less than 50 of these rules, it's quite a waste. So this time, there are minor UI changes: * The "expand/collapse all" buttons icon changed. It now uses the one from font-awesome. It's quite close but not exactly the same. * The layout is slightly different (you need to switch between two tabs to actually see the difference). Before this PR: <img width="719" height="515" alt="image" src="https://github.com/user-attachments/assets/1f067046-4ee9-49ee-bf38-50a8bf9888f2" /> With this PR: <img width="719" height="515" alt="image" src="https://github.com/user-attachments/assets/80331c98-1a1e-418f-b481-5b3f5c276926" /> With this, we will be able to go even further on reducing the page size next. =D This time, the DOM size itself reduced a bit but the difference is too small to be noteworthy. r? @samueltardieu changelog: Remove CSS bootstrap dependency
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.