Skip to content

Conversation

marcospb19
Copy link
Contributor

@marcospb19 marcospb19 commented Aug 29, 2021

And adding missing link to Duration from Instant.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 29, 2021
@marcospb19 marcospb19 changed the title Adding examples to docs of std::time module Adding examples to docs of std::time module Aug 29, 2021
@marcospb19
Copy link
Contributor Author

@joshtriplett I found the time module pretty empty, so I tried adding some examples to it, but I'm not sure if these examples should not be inside of Duration and Instant.

image

@marcospb19
Copy link
Contributor Author

marcospb19 commented Aug 29, 2021

I also thought about changing some in Duration (here's the current snippet):

use std::time::Duration;

let five_seconds = Duration::new(5, 0);
let five_seconds_and_five_nanos = five_seconds + Duration::new(0, 5);

assert_eq!(five_seconds_and_five_nanos.as_secs(), 5);
assert_eq!(five_seconds_and_five_nanos.subsec_nanos(), 5);

let ten_millis = Duration::from_millis(10);

The reason: I don't think new is as good as from_* to create a Duration.

I would prefer

let five_seconds = Duration::from_secs(5);

Instead of

let five_seconds = Duration::new(5, 0);

@rust-log-analyzer

This comment has been minimized.

@marcospb19 marcospb19 marked this pull request as draft August 29, 2021 19:32
@rust-log-analyzer

This comment has been minimized.

And adding missing link to Duration from Instant
@marcospb19 marcospb19 marked this pull request as ready for review August 30, 2021 03:07
@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 30, 2021

📌 Commit faf5985 has been approved by joshtriplett

@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 Aug 30, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 31, 2021
Rollup of 14 pull requests

Successful merges:

 - rust-lang#88394 (Document `std::env::current_exe` possible rename behaviour)
 - rust-lang#88406 (Tait nest infer test)
 - rust-lang#88408 (Add inference cycle TAIT test)
 - rust-lang#88409 (Add auto trait leakage TAIT test)
 - rust-lang#88413 (Add weird return types TAIT test)
 - rust-lang#88450 (fix(rustc_parse): correct span in `maybe_whole_expr!`)
 - rust-lang#88462 (rustdoc: Stop using resolver for macro loading)
 - rust-lang#88465 (Adding examples to docs of `std::time` module)
 - rust-lang#88486 (Remove unused arena macro args)
 - rust-lang#88492 (Use MaybeUninit::write in functor.rs)
 - rust-lang#88496 (Fix prelude collision lint suggestion for generics with lifetimes)
 - rust-lang#88497 (Fix prelude collision suggestions for glob imported traits. )
 - rust-lang#88503 (Warn when [T; N].into_iter() is ambiguous in the new edition. )
 - rust-lang#88509 (Don't suggest extra <> in dyn suggestion.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 497267a into rust-lang:master Aug 31, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 31, 2021
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants