Enable instant only for wasm32 targets

... and hide the dependency under a `time` module in `iced_native`
This commit is contained in:
Héctor Ramón Jiménez 2022-01-28 17:05:09 +07:00
parent 776724162a
commit 87b3e03d18
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
6 changed files with 19 additions and 6 deletions

View file

@ -1,5 +1,7 @@
#![allow(missing_docs)]
use std::{collections::VecDeque, time};
use crate::time;
use std::collections::VecDeque;
/// A bunch of time measurements for debugging purposes.
#[derive(Debug)]

View file

@ -49,6 +49,7 @@ pub mod renderer;
pub mod subscription;
pub mod svg;
pub mod text;
pub mod time;
pub mod touch;
pub mod user_interface;
pub mod widget;

View file

@ -1,6 +1,6 @@
//! Track mouse clicks.
use crate::time::Instant;
use crate::Point;
use instant::Instant;
/// A mouse click.
#[derive(Debug, Clone, Copy)]

7
native/src/time.rs Normal file
View file

@ -0,0 +1,7 @@
//! Keep track of time, both in native and web platforms!
#[cfg(target_arch = "wasm32")]
pub use instant::{Duration, Instant};
#[cfg(not(target_arch = "wasm32"))]
pub use std::time::{Duration, Instant};