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

Document Rc<T> #19112

Merged
merged 1 commit into from
Nov 27, 2014
Merged

Document Rc<T> #19112

merged 1 commit into from
Nov 27, 2014

Conversation

steveklabnik
Copy link
Member

No description provided.

@@ -201,7 +211,17 @@ impl<T> Rc<T> {
}
}

/// Downgrades the reference-counted pointer to a weak reference.
/// Downgrades the `Rc<T>` to a `Weak` reference.
Copy link
Contributor

Choose a reason for hiding this comment

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

You seem to use just Rc everywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, its just inconsistent. shrug

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we have no guideline here, I don't think :/

Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @aturon

Copy link
Member

Choose a reason for hiding this comment

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

Slight preference for Rc<T>, but feel free to make your own doc conventions for this kind of thing -- you can batch into a PR against https://github.com/rust-lang/rust-guidelines or an RFC.

@steveklabnik
Copy link
Member Author

Rebased and squashed.

@steveklabnik steveklabnik force-pushed the doc_rc branch 2 times, most recently from 3bc3cab to a396a98 Compare November 24, 2014 18:43
/// Drops the `Rc<T>`.
///
/// This will decrement the strong reference count. If the strong reference count becomes zero
/// and the only other references are `Weak<T>` ones, `drop` the inner value.
Copy link
Contributor

Choose a reason for hiding this comment

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

drops?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's more consistent.

/// A weak reference to a reference-counted pointer.
/// A weak version of `Rc<T>`.
///
/// Weak references do not count when determining if the inner value should be deallocated.
Copy link
Contributor

Choose a reason for hiding this comment

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

Another tricky case of deallocate vs drop.

@steveklabnik
Copy link
Member Author

@gankro updated, I think!

@@ -60,8 +58,8 @@
//! // Despite dropping gadget_owner, we're still able to print out the name of
//! // the Owner of the Gadgets. This is because we've only dropped the
//! // reference count object, not the Owner it wraps. As long as there are
//! // other Rc objects pointing at the same Owner, it will stay alive. Notice
//! // that the Rc wrapper around Gadget.owner gets automatically dereferenced
//! // other `Rc<T>` objects pointing at the same Owner, it will remain allocaed. Notice
Copy link
Contributor

Choose a reason for hiding this comment

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

s/allocaed/allocated

Copy link
Member Author

Choose a reason for hiding this comment

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

that's what I get for touching other people's prose 😉

updated!

This commit introduces a bunch of documentation, fixes some consistency
issues, and just basically brings Rc<T> and Weak<T> up to snuff.
///
/// Unique ownership means that there are no other `Rc` or `Weak` values
/// that share the same contents.
/// rc::is_unique(&five);
Copy link
Contributor

Choose a reason for hiding this comment

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

No asserts still feels weird to me. shrug

@Gankra
Copy link
Contributor

Gankra commented Nov 25, 2014

This basically LGTM now. I don't think we should bother doc'ing le/ge/eq/etc. I also just realized we should just be able to axe those in favour of auto or manual deref. The only downside is

my_rc1 < my_rc2 => *my_rc1 < *my_rc2

Not sure what the total plans for operators like that is. I'll defer to @japaric and @aturon on that matter.

@steveklabnik
Copy link
Member Author

I only documneted them because it does something interesting, which seemed like the bar. Not opposed to axing them.

@Gankra
Copy link
Contributor

Gankra commented Nov 25, 2014

It does exactly what you'd expect every smart pointer to do, right?

@bors bors closed this Nov 27, 2014
@bors bors merged commit a1d983a into rust-lang:master Nov 27, 2014
@steveklabnik steveklabnik deleted the doc_rc branch October 25, 2017 18:27
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.

7 participants