Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ivan-shrimp
Copy link
Contributor

NonZero's doctests contain both ? and .unwrap() with no obvious reason for the difference, so this changes all of them to ?. Also removes an explicit std::num::NonZero.

@rustbot
Copy link
Collaborator

rustbot commented Jun 9, 2024

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 9, 2024
/// # use std::num::NonZero;
/// #
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::new(", $leading_zeros_test, ").unwrap();")]
/// # fn main() { test().unwrap(); }
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I was going to say that this should be https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#using--in-doc-tests, but I think that only works for Result, so makes sense to have this dance.

@scottmcm
Copy link
Member

Hmm, personally I think that things like NonZero::new(10).unwrap() are entirely justified -- I'd never actually use ? for that in a real program because it's not a reachable error path -- but given the other examples using ? all over the place I agree it makes sense to unify things like this.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 10, 2024

📌 Commit 041e204 has been approved by scottmcm

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 10, 2024
@bors bors merged commit 146f4b3 into rust-lang:master Jun 10, 2024
@rustbot rustbot added this to the 1.81.0 milestone Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants