-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tweak std::rc docs #36571
Tweak std::rc docs #36571
Conversation
//! | ||
//! `Rc<T>` automatically dereferences to `T` (via the [`Deref`][deref] trait), | ||
//! so you can call `T`'s methods on a value of type `Rc<T>`. The methods of | ||
//! `Rc` itself, such as `downgrade`, are called using function-like syntax |
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.
Not a concrete suggestion, but these are called associated functions
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.
Cool; added a note.
//! Rc::downgrade(&my_rc); | ||
//! ``` | ||
//! | ||
//! to avoid name clashes with `T`'s methods. |
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.
Alternatively, in order to prevent the code block from breaking up the sentence, it could also be something like:
In order to avoid name clashes with
T
's methods, the methods ofRc
itself, such asdowngrade
, are called using function-like syntax:
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.
Good idea; fixed.
@@ -570,16 +681,16 @@ impl<T: ?Sized + PartialEq> PartialEq for Rc<T> { | |||
/// | |||
/// let five = Rc::new(5); | |||
/// | |||
/// five == Rc::new(5); | |||
/// assert!(five == Rc::new(5)); |
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.
Alternatively, assert_eq!
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 went with ==
because we're talking about the definition of ==
. Of course, assert_eq!
uses ==
but it's an extra layer of indirection.
@@ -588,7 +699,7 @@ impl<T: ?Sized + PartialEq> PartialEq for Rc<T> { | |||
/// | |||
/// let five = Rc::new(5); | |||
/// | |||
/// five != Rc::new(5); | |||
/// assert!(five != Rc::new(6)); |
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.
Alternatively, assert_eq!
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 think there's an assert_neq!
. Anyway, see above.
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.
Just kidding, missed the !=
. On a side note: rust-lang/rfcs#1653
btw, I'm updating |
3f6d2cb
to
c316ae5
Compare
Rebased and squashed. |
Thanks a lot! @bors: r+ rollup |
📌 Commit c316ae5 has been approved by |
…cs, r=GuillaumeGomez Tweak std::rc docs Fixes rust-lang#29372. r? @GuillaumeGomez
…cs, r=GuillaumeGomez Tweak std::rc docs Fixes rust-lang#29372. r? @GuillaumeGomez
Update Arc docs to match new Rc docs `Rc` docs were updated in rust-lang#36571. This applies similar changes to `Arc` docs. r? @GuillaumeGomez
Fixes #29372.
r? @GuillaumeGomez