Skip to content

Commit 10e17dc

Browse files
authored
Rollup merge of #139982 - coolreader18:time-doc-tweak, r=jhpratt
SystemTime doc tweaks * Change the `UNIX_EPOCH` link in the `SystemTime` docs to point to the associated constant, not the module level constant. The former seems to be the recommended way to access it, since aiui the only reason the module constant exists in the first place is that associated constants weren't stable yet at the time. * Reword the comment in the `SystemTime` example - "an error occurred!" is a tad misleading; I feel like it implies a system error out of our control while `SystemTimeError` is more of a logic error. I was originally just gonna do the first thing but I noticed the second and figured I may as well. I'm also somewhat surprised that there aren't more in-depth module level docs for `std::time`; they don't even mention `SystemTime` at all. I might make another PR for that but mainly just wanted to flag it.
2 parents 6925d2f + 34573d6 commit 10e17dc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/std/src/time.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ pub struct Instant(time::Instant);
205205
/// println!("{}", elapsed.as_secs());
206206
/// }
207207
/// Err(e) => {
208-
/// // an error occurred!
209-
/// println!("Error: {e:?}");
208+
/// // the system clock went backwards!
209+
/// println!("Great Scott! {e:?}");
210210
/// }
211211
/// }
212212
/// }
@@ -245,6 +245,7 @@ pub struct Instant(time::Instant);
245245
/// > structure cannot represent the new point in time.
246246
///
247247
/// [`add`]: SystemTime::add
248+
/// [`UNIX_EPOCH`]: SystemTime::UNIX_EPOCH
248249
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
249250
#[stable(feature = "time2", since = "1.8.0")]
250251
pub struct SystemTime(time::SystemTime);

0 commit comments

Comments
 (0)