We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8575691 commit 82a25eeCopy full SHA for 82a25ee
1 file changed
akaze/src/lib.rs
@@ -27,7 +27,11 @@ impl Instant {
27
fn now() -> Self {
28
#[cfg(feature = "web-sys")]
29
{
30
- Self(web_sys::window().unwrap().performance().unwrap().now())
+ Self(
31
+ web_sys::window()
32
+ .and_then(|w| w.performance())
33
+ .map_or(0., |p| p.now()),
34
+ )
35
}
36
#[cfg(not(feature = "web-sys"))]
37
@@ -37,9 +41,7 @@ impl Instant {
41
fn elapsed(&self) -> std::time::Duration {
38
42
39
43
40
- std::time::Duration::from_secs_f64(
- (web_sys::window().unwrap().performance().unwrap().now() - self.0) * 0.001,
- )
44
+ std::time::Duration::from_secs_f64((Self::now().0 - self.0) * 0.001)
45
46
47
0 commit comments