Conversation
…ime`s to clarify handling of failure
| /// | ||
| /// If successful, <code>[Ok]\([Duration])</code> is returned where the duration represents | ||
| /// the amount of time elapsed from the specified measurement to this one. | ||
| /// If `self` lies further ahead, or at the same point in time compared to `earlier`, |
There was a problem hiding this comment.
This seems a very roundabout way to express that earlier is not later than self.
| /// Also note that the `UNIX_EPOCH` may not be equal to the minimum representable | ||
| /// value of [`SystemTime`]; [`SystemTime::MIN`] is platform-dependent. | ||
| /// Thus, the developer ought to anticipate that comparison with `UNIX_EPOCH` may | ||
| /// result in "failure", even within legitimate, real-world use-cases. |
There was a problem hiding this comment.
One of the complaints was that pretending that the Err variant represents a failure contributes to wrong interpretation of the return value of this function.
| /// Returns an [`Err`] if `earlier` is later than `self`, and the error | ||
| /// contains how far from `self` the time is. | ||
| /// Returns an [`Err`] if `earlier` is later than `self`, where the error contains how far | ||
| /// from `self` the time is, publicly exposed through [`SystemTimeError::duration`]. |
There was a problem hiding this comment.
I'm not sure what "publicly exposed through" is supposed to mean.
| /// returned where the duration represents the amount of time elapsed from | ||
| /// This function may return a [`SystemTimeError`] as the underlying system clock | ||
| /// is susceptible to drift and updates (e.g., the system clock could go backwards), | ||
| /// so this function might not always succeed. If successful, an [`Ok::<Duration>`](Ok) |
There was a problem hiding this comment.
Another instance of the failure/success analogy which should be avoided.
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
Ping from triage: @david-d-h - can you post your status on this PR? I'll be closing because of inactivity otherwise. Thanks |
This documentation change is meant to clarify that
SystemTimes may (platform-dependently) be "less" than theUNIX_EPOCHand a developer ought to take care in comparing between the two, as this might lead to an error. It also explicitly mentionsSystemTimeError::durationfor when such an error does occur.I'm not sure on whether it would be helpful to document such a thing on the
SystemTimeitself rather than on it's methods and assoc consts? Perhaps it could be, since the documentation for the item also mentions theUNIX_EPOCHanchor and encourages comparisons with it. Anyways, open to suggestions.closes #52522