Skip to content
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

Merged
merged 2 commits into from
Jan 6, 2025
Merged

wasm as platform dependency #139

merged 2 commits into from
Jan 6, 2025

Conversation

goulart-paul
Copy link
Member

@goulart-paul goulart-paul commented Nov 26, 2024

Attempts to fix #134.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.12%. Comparing base (7036899) to head (96e5649).
Report is 6 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

Copy link

@lovasoa lovasoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great !

@goulart-paul goulart-paul changed the base branch from main to develop January 6, 2025 18:21
@goulart-paul goulart-paul merged commit bdbf909 into develop Jan 6, 2025
11 of 12 checks passed
goulart-paul added a commit that referenced this pull request Jan 6, 2025
Comment on lines 4 to 11
cfg_if::cfg_if! {
if #[cfg(feature="wasm")] {
if #[cfg(target_family = "wasm")] {
use web_time::{Duration, Instant};
}
else {
use std::time::{Duration, Instant};
}
}
Copy link

@lovasoa lovasoa Jan 7, 2025

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

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wasm feature flag instead of platform-dependent dependencies
2 participants