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

Doc:std::convert explicitely list generic impls #30901

Merged
merged 3 commits into from
Feb 1, 2016

Conversation

mackwic
Copy link
Contributor

@mackwic mackwic commented Jan 14, 2016

Also add a note about the necessary simplicity of the conversion.
Related issue: #29349

r? @steveklabnik

Also add a note about the necessary simplicity of the conversion.
Related issue: rust-lang#29349
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (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.

@mackwic
Copy link
Contributor Author

mackwic commented Jan 14, 2016

As a side note, I wrote nothing about #29701 as it wasn't crystal clear what has to be written about it (library writer has to document exactly when and how to use conversions ? Library user should not trust conversions for some contexts ?).

I am happy to change or reword anything, add references, links, or topics.

@@ -17,6 +17,26 @@
//! Like many traits, these are often used as bounds for generic functions, to
//! support arguments of multiple types.
//!
//! - Use `as` for reference-to-reference conversions
Copy link
Member

Choose a reason for hiding this comment

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

as is broader than this, actually. it's for any kind of basic cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The RFC which introduced them doesn't agree (ref) and has a nice rationale about it. If the rfc is still right, maybe explain further the motivation ?

Copy link
Member

Choose a reason for hiding this comment

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

This is about the as keyword, not the As* traits, no?

Copy link
Member

Choose a reason for hiding this comment

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

So yes, I think that all we need is proper capitalization/style here, to disambiguate from the keywords.

@steveklabnik
Copy link
Member

Thanks for this! Here's a first round of nitpics. I would also like to hear what @gankro and @aturon think about this, since they're guidelines. /cc @rust-lang/libs

@@ -30,6 +50,10 @@ use marker::Sized;
///
/// [book]: ../../book/borrow-and-asref.html
///
/// **Note:** these traits are for trivial conversion. **They must not fail**. If
Copy link
Member

Choose a reason for hiding this comment

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

It may be worth it to call out here that there's no technical reason why they should not fail right now, it's just idiomatic that they should never fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that a panic could be acceptable in this case or do you mean that implementing Into<Option<T>> is not idiomatic ?

Copy link
Member

Choose a reason for hiding this comment

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

Ah no panics are still "unacceptable" but not in the sense that something like unsafety will arise. It's just unidiomatic and can lead to bugs, so it's rather strongly recommended that conversions don't panic.

The wording currently implies to me that something very bad will happen if a panic happens during a conversions, but it should be pretty normal in terms of the outcome (the code just panics). It's just the standard worry about a function panicking.

@@ -17,6 +17,24 @@
//! Like many traits, these are often used as bounds for generic functions, to
//! support arguments of multiple types.
//!
//! - Use `as` for reference-to-reference conversions
//! - Use `into` when you want to consume the value
Copy link
Member

Choose a reason for hiding this comment

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

And this should be Into

@steveklabnik
Copy link
Member

Just those last bits of capitalization and r=me

@steveklabnik
Copy link
Member

(Sorry for not noticing this was updated, GitHub doesn't notify when a new commit is pushed :/

@mackwic
Copy link
Contributor Author

mackwic commented Jan 31, 2016

I missed the github notification, sorry. Here is a disambiguation, it was indeed confusing.

@steveklabnik
Copy link
Member

@bors: r+ rollup

Thanks a ton!

@bors
Copy link
Contributor

bors commented Feb 1, 2016

📌 Commit a0cd465 has been approved by steveklabnik

@bors
Copy link
Contributor

bors commented Feb 1, 2016

⌛ Testing commit a0cd465 with merge 2849ca6...

bors added a commit that referenced this pull request Feb 1, 2016
Also add a note about the necessary simplicity of the conversion.
Related issue: #29349

r? @steveklabnik
@bors bors merged commit a0cd465 into rust-lang:master Feb 1, 2016
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