-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm as platform dependency #139
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #139 +/- ##
===========================================
- Coverage 88.14% 88.12% -0.02%
===========================================
Files 77 77
Lines 6189 6189
===========================================
- Hits 5455 5454 -1
- Misses 734 735 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great !
cfg_if::cfg_if! { | ||
if #[cfg(feature="wasm")] { | ||
if #[cfg(target_family = "wasm")] { | ||
use web_time::{Duration, Instant}; | ||
} | ||
else { | ||
use std::time::{Duration, Instant}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goulart-paul Is there a reason to use cfg-if here ? (Instead of just adding the #cfg
attribute directly ?
#[cfg(target_family = "wasm")]
use web_time::{Duration, Instant};
#[cfg(not(target_family = "wasm"))]
use std::time::{Duration, Instant};
https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think either way works. Maybe the current way is slightly preferable since it presents the cases as mutually exclusive options?
We already depend on cfg-if anyway since it is used when configuring basic types with/without BLAS support, and there cfg-if is quite useful since the else
blocks can have (marginally) more substance.
Attempts to fix #134.