Skip to content

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

Merged
merged 1 commit into from
Jul 1, 2014
Merged

Improve Rc documentation #15251

merged 1 commit into from
Jul 1, 2014

Conversation

AlisdairO
Copy link
Contributor

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.

@@ -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
Copy link
Member

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

Copy link
Contributor Author

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 :-).

Copy link
Member

Choose a reason for hiding this comment

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

After the #.

Copy link
Contributor Author

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.

@steveklabnik
Copy link
Member

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;
Copy link
Member

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.

@AlisdairO
Copy link
Contributor Author

Thanks for the comments - I've updated to resolve the issues you raised. The only one I couldn't fix was making an actual link to the Cell docs, as I don't know how to make a link in rustdoc: the docs seem to suggest that free text @see equivalents don't exist at the moment.

@alexcrichton
Copy link
Member

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.

@AlisdairO
Copy link
Contributor Author

@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?

@alexcrichton
Copy link
Member

It's ok to ignore an error like that on travis, it's likely just spurious

@AlisdairO
Copy link
Contributor Author

OK great - I've squashed it now.

bors added a commit that referenced this pull request Jul 1, 2014
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.
@bors bors closed this Jul 1, 2014
@bors bors merged commit 88008b3 into rust-lang:master Jul 1, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2023
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.
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.

5 participants