# Move \`Instant\` into core?

**URL:** <https://internals.rust-lang.org/t/move-instant-into-core/20734>\
**Category:** libs\
**Created:** [April 28, 2024, 9:18am UTC](https://internals.rust-lang.org/t/move-instant-into-core/20734 "2024-04-28T09:18:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chiichen](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/chiichen/32/12102_2.png) [@Chiichen](https://internals.rust-lang.org/u/Chiichen)\
**Post date:** [April 28, 2024, 9:18am UTC](https://internals.rust-lang.org/t/move-instant-into-core/20734/1 "2024-04-28T09:18:11Z")

</div>

I think, in Instant, only `now()` method is platform dependent, moving `Instant` abstraction except `now()` method into `core` is not a difficult job (just need to The now method is not provided in the no\_std environment), and this can play a great role in many no\_std scenarios (such as embedded).

## Why

1. For example, I now want to implement a timer (for example, 5 seconds) in an embedded scenario. Then I actually just want to know, from the given timing zero point (`Instant::zero()`), the current time (` get_time()` or calculated through `tick`), whether the specified time interval has been exceeded (`Duration::from_secs(5)`), all these calculations can actually be done with `Instant::now()` Separately, this allows us to calculate the Instant through multiple methods, whether it is calculated indirectly from the tick or directly obtains the current time through a system call.
2. Instant itself is just an abstract concept by design, which is why many platforms define Instant as `Instant(Duration)` in the standard library. I think Instant itself should be an abstract concept that appears in pairs with Duration, such as ` Instant(0)+Duration(5) = Instant(5)`, just `Instant::now()`, as a function that requires system support, needs to be supported by std

---

<div class="post-metadata">

**Author:** ![burntsushi](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/burntsushi/32/279_2.png) [@burntsushi](https://internals.rust-lang.org/u/burntsushi)\
**Post date:** [April 28, 2024, 11:58am UTC](https://internals.rust-lang.org/t/move-instant-into-core/20734/2 "2024-04-28T11:58:47Z")

</div>

I don't understand how you can use `Instant` without `Instant::now`. That's the only way to construct an `Instant`. You seem to mention other methods like `Instant::zero` (and maybe `Instant::tick`?), but you don't define their semantics or show an example of their use. I'd suggest focusing more on those first, with "more to core" as a longer term goal.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [July 27, 2024, 11:59am UTC](https://internals.rust-lang.org/t/move-instant-into-core/20734/3 "2024-07-27T11:59:23Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
