From 939f05f3e33e9f00d5205d60af3a862ae4d58bd6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Feb 2020 12:43:56 +0100 Subject: Move to a crate --- crates/ra_ide_db/src/wasm_shims.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 crates/ra_ide_db/src/wasm_shims.rs (limited to 'crates/ra_ide_db/src/wasm_shims.rs') diff --git a/crates/ra_ide_db/src/wasm_shims.rs b/crates/ra_ide_db/src/wasm_shims.rs new file mode 100644 index 000000000..088cc9be4 --- /dev/null +++ b/crates/ra_ide_db/src/wasm_shims.rs @@ -0,0 +1,19 @@ +//! FIXME: write short doc here + +#[cfg(not(feature = "wasm"))] +pub use std::time::Instant; + +#[cfg(feature = "wasm")] +#[derive(Clone, Copy, Debug)] +pub struct Instant; + +#[cfg(feature = "wasm")] +impl Instant { + pub fn now() -> Self { + Self + } + + pub fn elapsed(&self) -> std::time::Duration { + std::time::Duration::new(0, 0) + } +} -- cgit v1.2.3 From 355c98fd0861acf0f0fddad08cbc923fee0698fb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Feb 2020 15:08:31 +0100 Subject: Docs --- crates/ra_ide_db/src/wasm_shims.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide_db/src/wasm_shims.rs') diff --git a/crates/ra_ide_db/src/wasm_shims.rs b/crates/ra_ide_db/src/wasm_shims.rs index 088cc9be4..7af9f9d9b 100644 --- a/crates/ra_ide_db/src/wasm_shims.rs +++ b/crates/ra_ide_db/src/wasm_shims.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! A version of `std::time::Instant` that doesn't panic in WASM. #[cfg(not(feature = "wasm"))] pub use std::time::Instant; -- cgit v1.2.3