-
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
API docs: Convert #40987
API docs: Convert #40987
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Looks like our tidy checker wants some lines wrapped:
|
Thanks just confirmed with @steveklabnik that want standard library docs wrapped to 80 characters so that should address that 😄 |
Broken links this time will fix next chance I get.
|
Closing until I get a clean build, have realized not yet ready. |
ping @steveklabnik @frewsxcv -- looks like this is passing and ready for r now? |
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.
thanks for this! Looks great overall but there's some formatting details to take care of. We're good to go after they're fixed.
src/libcore/convert.rs
Outdated
//! - [`From`] and [`Into`] are reflexive, which means that all types can `into()` | ||
//! themselves and `from()` themselves | ||
//! - [`From`] and [`Into`] are reflexive, which means that all types can | ||
//! `into()` themselves and `from()` themselves |
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.
very minor nit: the ()
s shouldn't be here. Not your fault, but while you're here, fixing them would be nice, on both into
and from
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 problem, boy scout rule applied 🤓
@@ -50,20 +50,41 @@ | |||
|
|||
use str::FromStr; | |||
|
|||
/// A cheap, reference-to-reference conversion. | |||
/// A cheap reference-to-reference conversion. Used to convert a value to a | |||
/// reference value within generic code. |
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 wonder if this isn't too long for a summary line; it might get cut off on https://doc.rust-lang.org/stable/std/convert/index.html. Have you checked? if not, maybe
A cheap reference-to-reference conversion, used within generic code.
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.
src/libcore/convert.rs
Outdated
/// useful when wishing to abstract | ||
/// over the type of reference (`&T`, `&mut T`) or allow both the referenced | ||
/// and owned type to be treated in the same manner. | ||
/// The key difference between the two traits is the intention: |
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.
could you put a ///
above this line?
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.
Done
src/libcore/convert.rs
Outdated
/// `Borrow` is more related to the notion of taking the reference. It is | ||
/// useful when wishing to abstract | ||
/// over the type of reference (`&T`, `&mut T`) or allow both the referenced | ||
/// and owned type to be treated in the same manner. |
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.
everything above here is treated as one paragraph in markdown, but are broken up strangely in the text, could you reflow this paragraph please?
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 don't know what happened here. Reshaped into a clearer single paragraph.
src/libcore/convert.rs
Outdated
/// | ||
/// - Use `AsRef` when goal is to simply convert into a reference | ||
/// - Use `Borrow` when goal is related to writing code that is agnostic to the | ||
/// type of borrow and if is reference or value |
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 think this needs to be indented to match up with the Use
above; not 100% sure though
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.
Looks neater anyway so will indent them, it appeared to render fine though 😄
src/libcore/convert.rs
Outdated
/// # Generic Implementations | ||
/// | ||
/// - `AsRef` auto-dereferences if the inner type is a reference or a mutable | ||
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type |
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.
same here, dunno if these lines need to be indented
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.
Indented
src/libcore/convert.rs
Outdated
/// # Generic Implementations | ||
/// | ||
/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable | ||
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type |
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.
and here
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.
And indented again 😄
src/libcore/convert.rs
Outdated
/// erroneous situations. | ||
/// This trait is not limited to error handling, rather the general case for | ||
/// this trait would be in any type conversions to have an explicit definition | ||
/// of how they are performed. |
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.
these three paragraphs will get smooshed into one by markdown; could you add ///
lines between them?
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.
Yes my bad. Now separated.
src/libcore/convert.rs
Outdated
@@ -236,15 +310,19 @@ pub trait TryFrom<T>: Sized { | |||
|
|||
// As lifts over & | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl<'a, T: ?Sized, U: ?Sized> AsRef<U> for &'a T where T: AsRef<U> { | |||
impl<'a, T: ?Sized, U: ?Sized> AsRef<U> for &'a T |
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.
all the changes from here below are re-styling code and probably don't belong here
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 formatter got the best of me. Reverting these changes.
Looks like this was updated, mind taking another look @steveklabnik and/or @frewsxcv? @maccoda also when you update a PR feel free to ping it, unfortunately github doesn't send out notifications for updating a PR :( |
📌 Commit 2877a01 has been approved by |
API docs: Convert Clean up of the convert module documentation following points in rust-lang#29349
@alexcrichton thank you for that didn't know didn't send notifications will remember to do this next time! @steveklabnik thank you, look forward to working on the next one |
Clean up of the convert module documentation following points in #29349