Add a pure now helper to time module
This commit is contained in:
parent
ebe223cb5d
commit
d9f24dddb9
1 changed files with 14 additions and 0 deletions
14
src/time.rs
14
src/time.rs
|
|
@ -11,3 +11,17 @@ pub use crate::core::time::*;
|
|||
)))
|
||||
)]
|
||||
pub use iced_futures::backend::default::time::*;
|
||||
|
||||
use crate::Task;
|
||||
|
||||
/// Returns a [`Task`] that produces the current [`Instant`]
|
||||
/// by calling [`Instant::now`].
|
||||
///
|
||||
/// While you can call [`Instant::now`] directly in your application,
|
||||
/// this is an "impure" operation (i.e. it's not referentially transparent).
|
||||
///
|
||||
/// You may care about purity if you want to leverage the `time-travel`
|
||||
/// feature properly.
|
||||
pub fn now() -> Task<Instant> {
|
||||
Task::future(async { Instant::now() })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue