Improve documentation for rand::random#15746
Improve documentation for rand::random#15746steveklabnik wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
/cc @huonw |
There was a problem hiding this comment.
Is there a reason you removed the if random() part of the example as well?
Also, is it worth having a comment here indicating the inference is running "backwards"?
There was a problem hiding this comment.
+1 for re-addition of if random()
There was a problem hiding this comment.
Yes, without explanation, I had no idea why it was even there. Now that you've mentioned it, it's to demonstrate that it can generate a boolean? I'd be about putting that back with a comment explaining that.
There was a problem hiding this comment.
It was there to demonstrate a variety of ways in which the type of the return value can be inferred.
There was a problem hiding this comment.
Yeah, this makes sense looking back. Without context, I had no idea.
There was a problem hiding this comment.
Yeah, other people have actually had confusion too for the similar example in the main module doc string: http://stackoverflow.com/q/24153311/1256624
|
Added the I don't think it's worth talking as much about the inference because that's how inference works in general, and this is an API doc. |
I was thinking in the context of the first doc page the people land on from the new guide; and, this form of "raw" return type deduction isn't super-common, so having more examples is better than having fewer, IMO. |
|
That's true. Let's see how it goes. In the guide, I explicitly talk about the |
|
Whoops. Fixed. |
This is now linked to in the guide, so I want to make sure it's good. This adds a bit more explanation, and brings usage in line with current good style.
|
😢 I ❤️ you @bors. pleeeeease do it this time. |
|
@alexcrichton looks like @bors needs a retry |
This is now linked to in the guide, so I want to make sure it's good. This adds a bit more explanation, and brings usage in line with current good style.
…=Veykril String literals diagnose Continues the work from rust-lang#15744 to add diagnosis errors to Str, ByteStr, and CStr literal kinds. Also replaces `unescape_char` for `unescape_byte` to use the correct method for Byte literals.
…ng#15746) This might be due to a low edition (< 2024) or too low a MSRV. In this case, we will suggest only `match`. Fixes rust-lang/rust-clippy#15744 changelog: [`unnecessary_unwrap`]: do not suggest using `if let` chains if this is not supported with the current edition or MSRV changelog:[`collapsible_if`]: Do not suggest using `if let` if this is not supported with the current edition or MSRV
This is now linked to in the guide, so I want to make sure it's good. This
adds a bit more explanation, and brings usage in line with current good style.